Skip to content

Instantly share code, notes, and snippets.

@osiro
Created May 22, 2014 08:08
Show Gist options
  • Save osiro/813eb0682f1a4c352090 to your computer and use it in GitHub Desktop.
Save osiro/813eb0682f1a4c352090 to your computer and use it in GitHub Desktop.
em-funding_development=# EXPLAIN ANALYZE SELECT "projects".*, ((ts_rank((to_tsvector('english', coalesce("projects"."title"::text, '')) || to_tsvector('english', coalesce("projects"."description"::text, ''))), (to_tsquery('english', ''' ' || 'qui' || ' ''')), 0))) AS pg_search_rank FROM "projects" WHERE (((to_tsvector('english', coalesce("projects"."title"::text, '')) || to_tsvector('english', coalesce("projects"."description"::text, ''))) @@ (to_tsquery('english', ''' ' || 'qui' || ' ''')))) ORDER BY pg_search_rank DESC, "projects"."id" ASC;
QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Sort (cost=12.09..12.10 rows=2 width=292) (actual time=0.242..0.242 rows=2 loops=1)
Sort Key: (ts_rank((to_tsvector('english'::regconfig, COALESCE((title)::text, ''::text)) || to_tsvector('english'::regconfig, COALESCE(description, ''::text))), '''qui'''::tsquery, 0)), id
Sort Method: quicksort Memory: 26kB
-> Bitmap Heap Scan on projects (cost=8.02..12.08 rows=2 width=292) (actual time=0.132..0.232 rows=2 loops=1)
Recheck Cond: ((to_tsvector('english'::regconfig, COALESCE((title)::text, ''::text)) || to_tsvector('english'::regconfig, COALESCE(description, ''::text))) @@ '''qui'''::tsquery)
-> Bitmap Index Scan on index_project_tsearch_title_description (cost=0.00..8.02 rows=2 width=0) (actual time=0.018..0.018 rows=2 loops=1)
Index Cond: ((to_tsvector('english'::regconfig, COALESCE((title)::text, ''::text)) || to_tsvector('english'::regconfig, COALESCE(description, ''::text))) @@ '''qui'''::tsquery)
Total runtime: 0.285 ms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment