Skip to content

Instantly share code, notes, and snippets.

@teburd
Last active December 17, 2015 05:09
Show Gist options
  • Save teburd/5555907 to your computer and use it in GitHub Desktop.
Save teburd/5555907 to your computer and use it in GitHub Desktop.
TSearch Or with order by and lmit
QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------------------------------------------
Limit (cost=6391.54..6391.79 rows=100 width=109) (actual time=29.755..29.768 rows=100 loops=1)
-> Sort (cost=6391.54..6402.75 rows=4484 width=109) (actual time=29.754..29.759 rows=100 loops=1)
Sort Key: ((ts_rank(name_fts, plainto_tsquery('school'::text)) + ts_rank(description_fts, plainto_tsquery('school'::text))))
Sort Method: top-N heapsort Memory: 32kB
-> Bitmap Heap Scan on vertices (cost=76.15..6220.17 rows=4484 width=109) (actual time=3.497..28.446 rows=3824 loops=1)
Recheck Cond: ((name_fts @@ plainto_tsquery('school'::text)) OR (description_fts @@ plainto_tsquery('school'::text)))
-> BitmapOr (cost=76.15..76.15 rows=4521 width=0) (actual time=2.839..2.839 rows=0 loops=1)
-> Bitmap Index Scan on vertices_name_fts_gin_idx (cost=0.00..36.94 rows=2258 width=0) (actual time=1.484..1.484 rows=2307 loops=1)
Index Cond: (name_fts @@ plainto_tsquery('school'::text))
-> Bitmap Index Scan on vertices_description_fts_gin_idx (cost=0.00..36.97 rows=2263 width=0) (actual time=1.352..1.352 rows=2255 loops=1)
Index Cond: (description_fts @@ plainto_tsquery('school'::text))
Total runtime: 29.872 ms
(12 rows)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment