SELECT * FROM datasets
WHERE
datasets.notes ILIKE '%test%' OR
datasets_id IN (1,2,3)
Explain output for this query:
"Bitmap Heap Scan on datasets (cost=41.98..385.13 rows=90 width=1428) (actual time=0.593..7.194 rows=1100 loops=1)"
" Recheck Cond: ((notes ~~* '%test%'::text) OR (datasets_id = ANY ('{1,2,3}'::integer[])))"
" Rows Removed by Index Recheck: 16"
" Heap Blocks: exact=1054"
" Buffers: shared hit=1107"
" -> BitmapOr (cost=41.98..41.98 rows=90 width=0) (actual time=0.428..0.428 rows=0 loops=1)"
" Buffers: shared hit=21"
" -> Bitmap Index Scan on datasets_notes_trgm_idx (cost=0.00..28.66 rows=87 width=0) (actual time=0.401..0.401 rows=1113 loops=1)"
" Index Cond: (notes ~~* '%test%'::text)"
" Buffers: shared hit=12"
" -> Bitmap Index Scan on datasets_pkey (cost=0.00..13.28 rows=3 width=0) (actual time=0.019..0.019 rows=3 loops=1)"
" Index Cond: (datasets_id = ANY ('{1,2,3}'::integer[]))"
" Buffers: shared hit=9"
"Planning time: 0.543 ms"
"Execution time: 10.034 ms"