Академический Документы
Профессиональный Документы
Культура Документы
3. Auxiliary Functions
• what are they, what they can do and how they might be extended
3. Auxiliary Functions
• what are they, what they can do and how they might be extended
● And so on..
Precedence & Parenthesis
● Precedence, from tightest to loosest grouping:
– NOT
– AND
– OR
● You can use parenthesis. So these are the
same:
SELECT * FROM ft WHERE ft MATCH 'yellow AND grey OR red'
SELECT * FROM ft WHERE ft MATCH 'red OR yellow AND grey'
SELECT * FROM ft WHERE ft MATCH 'red OR (yellow AND grey)'
3. Auxiliary Functions
• what are they, what they can do and how they might be extended
● It uses:
SELECT cmp(c1) AS a, cmp(c2) AS b ...
INSERT INTO %_content VALUES($rowid, uncmp(?), uncmp(?));
● To update a row:
UPDATE ft SET a=?, b=? WHERE rowid=?;
UPDATE tbl SET a=?, b=? WHERE rowid=?; Order matters!
External Content Tables
● The external content table doesn't actually have
to be a table. Just something (a table, a view, a
virtual table) that supports the following:
3. Auxiliary Functions
• what are they, what they can do and how they might be extended
snippet() returns
this text
position lists
● Doclists:
“purple” -> (1: a0 b2) (2: b3) (3: a0 b1) (4: b1)
“yellow” -> (2: a0 b2 b4) (4: a0)
3. Auxiliary Functions
• what are they, what they can do and how they might be extended
Level 0:
Once there are 16 trees in level 0,
Level 1: their contents are merged into a
single big level 1 tree (and the
original level 0 trees discarded)
Level 2:
And once there are 16 trees in
level 1, a level 2 tree... And so on
FTS Index Details: 'optimize'
● Querying multiple trees is slower than querying
a single tree.
● To merge all trees in an FTS index to a single
tree:
INSERT INTO ft(ft) VALUES('optimize');
Level 0:
After adding a level 0 tree, also
Level 1: do some work merging (say) level 1
Trees to level 0.
3. Auxiliary Functions
• what are they, what they can do and how they might be extended
● FTS5:
And there is a b-tree
Doclist is divided into a sequence of blobs to index it by docid
“am” ->
Large Doclists in FTS5
● So, when querying for:
SELECT count(*) FROM poiFtsTable
WHERE poiFtsTable MATCH 'am faltenbach'