Skip to content

Instantly share code, notes, and snippets.

@caspg
Last active March 3, 2020 14:02
Show Gist options
  • Save caspg/f82d26e2343e6a5907c47bbf24188fdb to your computer and use it in GitHub Desktop.
Save caspg/f82d26e2343e6a5907c47bbf24188fdb to your computer and use it in GitHub Desktop.
--------------------------------------------------------------------------------
JobPost.faster_search("ruby on rails").limit(10).explain
--------------------------------------------------------------------------------
Limit (cost=32.64..40.68 rows=1 width=416)
-> Nested Loop (cost=32.64..40.68 rows=1 width=416)
-> HashAggregate (cost=32.36..32.37 rows=1 width=8)
Group Key: job_post_searches.job_post_id
-> Sort (cost=32.34..32.35 rows=1 width=752)
Sort Key: (ts_rank(job_post_searches_1.tsv_document, '''rubi'' & ''rail'''::tsquery, 0)), job_post_searches.job_post_id
-> Nested Loop (cost=20.29..32.33 rows=1 width=752)
-> Bitmap Heap Scan on job_post_searches job_post_searches_1 (cost=20.00..24.01 rows=1 width=752)
Recheck Cond: (tsv_document @@ '''rubi'' & ''rail'''::tsquery)
-> Bitmap Index Scan on index_job_post_searches_on_tsv_document (cost=0.00..20.00 rows=1 width=0)
Index Cond: (tsv_document @@ '''rubi'' & ''rail'''::tsquery)
-> Index Only Scan using index_job_post_searches_on_job_post_id on job_post_searches (cost=0.29..8.30 rows=1 width=8)
Index Cond: (job_post_id = job_post_searches_1.job_post_id)
-> Index Scan using job_posts_pkey on job_posts (cost=0.29..8.30 rows=1 width=416)
Index Cond: (id = job_post_searches.job_post_id)
(15 rows)
--------------------------------------------------------------------------------
JobPost.faster_search("ruby on rails").explain
--------------------------------------------------------------------------------
Nested Loop (cost=32.64..40.68 rows=1 width=416)
-> HashAggregate (cost=32.36..32.37 rows=1 width=8)
Group Key: job_post_searches.job_post_id
-> Sort (cost=32.34..32.35 rows=1 width=752)
Sort Key: (ts_rank(job_post_searches_1.tsv_document, '''rubi'' & ''rail'''::tsquery, 0)), job_post_searches.job_post_id
-> Nested Loop (cost=20.29..32.33 rows=1 width=752)
-> Bitmap Heap Scan on job_post_searches job_post_searches_1 (cost=20.00..24.01 rows=1 width=752)
Recheck Cond: (tsv_document @@ '''rubi'' & ''rail'''::tsquery)
-> Bitmap Index Scan on index_job_post_searches_on_tsv_document (cost=0.00..20.00 rows=1 width=0)
Index Cond: (tsv_document @@ '''rubi'' & ''rail'''::tsquery)
-> Index Only Scan using index_job_post_searches_on_job_post_id on job_post_searches (cost=0.29..8.30 rows=1 width=8)
Index Cond: (job_post_id = job_post_searches_1.job_post_id)
-> Index Scan using job_posts_pkey on job_posts (cost=0.29..8.30 rows=1 width=416)
Index Cond: (id = job_post_searches.job_post_id)
(14 rows)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment