| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
SQLite allows for UNIONs and INTERSECTIONs between SELECT statements,
but it does not support grouping them. By recursively applying DeMorgan's
laws, the parser can reduce the parse tree to only
* Literals
* NOT literals (i.e. "all items not belonging to this tag")
* ANDs
* ORs
What SQLite /can/ do is have SELECT statements come from other SELECT
statements. A query like (X & Y & Z) | (A & B & C) in pseudo-SQLite
becomes
SELECT * FROM (
SELECT * FROM tbl WHERE name IN X
INTERSECTION
SELECT * FROM tbl WHERE name IN Y
INTERSECTION
SELECT * FROM tbl WHERE name IN Z
)
UNION
SELECT * FROM (
SELECT * FROM tbl WHERE name IN A
INTERSECTION
SELECT * FROM tbl WHERE name IN B
INTERSECTION
SELECT * FROM tbl WHERE name IN C
)
One future optimization would be to group all literals at a certain
level with each other, so that there are less direct queries to the
entire tag table.
|