Skip to content

Commit

Permalink
feat(query): use LIKELY() to improve query performance (#218)
Browse files Browse the repository at this point in the history
  • Loading branch information
missinglink committed Dec 13, 2021
1 parent a60df73 commit 92c175d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions query/match_subject_object_geom_intersects.sql
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ FROM fulltext f1
JOIN tokens t2 ON (
f2.rowid = t2.rowid
AND r2.id = t2.id
AND t2.token = $object
AND LIKELY(t2.token = $object)
AND (
t1.lang = t2.lang OR
t1.lang IN ('eng', 'und') OR
t2.lang IN ('eng', 'und')
)
)
WHERE f1.fulltext MATCH $subject_quoted
AND t1.token = $subject
AND LIKELY(t1.token = $subject)
GROUP BY t1.id, t2.id
ORDER BY t1.id ASC, t2.id ASC
LIMIT $limit
4 changes: 2 additions & 2 deletions query/match_subject_object_geom_intersects_autocomplete.sql
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ FROM fulltext f1
JOIN tokens t2 ON (
f2.rowid = t2.rowid
AND r2.id = t2.id
AND (t2.token = $object OR t2.token LIKE ($object || '%'))
AND LIKELY(t2.token = $object OR t2.token LIKE ($object || '%'))
AND (
t1.lang = t2.lang OR
t1.lang IN ('eng', 'und') OR
t2.lang IN ('eng', 'und')
)
)
WHERE f1.fulltext MATCH $subject_quoted
AND t1.token = $subject
AND LIKELY(t1.token = $subject)
GROUP BY t1.id, t2.id
ORDER BY t1.id ASC, t2.id ASC
LIMIT $limit

0 comments on commit 92c175d

Please sign in to comment.