Skip to content

Instantly share code, notes, and snippets.

@mkubala
Created July 10, 2020 11:51
Show Gist options
  • Save mkubala/64bfd0795eb04b51088acfcca9076cbf to your computer and use it in GitHub Desktop.
Save mkubala/64bfd0795eb04b51088acfcca9076cbf to your computer and use it in GitHub Desktop.
explain analyze select * from journal where deleted = false and tags @> ARRAY[3] and ordering > 1000 and ordering <= 3000 ORDER BY ordering asc limit 1000;
QUERY PLAN
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Limit (cost=332499.55..332499.60 rows=20 width=325) (actual time=9742.235..9742.267 rows=200 loops=1)
-> Sort (cost=332499.55..332499.60 rows=20 width=325) (actual time=9742.234..9742.249 rows=200 loops=1)
Sort Key: journal_0_0.ordering
Sort Method: quicksort Memory: 53kB
-> Append (cost=12.03..332499.12 rows=20 width=325) (actual time=2902.069..9742.207 rows=200 loops=1)
-> Bitmap Heap Scan on journal_0_0 (cost=12.03..33237.63 rows=1 width=54) (actual time=992.693..992.693 rows=0 loops=1)
Recheck Cond: ((ordering > 1000) AND (ordering <= 3000))
Rows Removed by Index Recheck: 9999799
Filter: ((NOT deleted) AND (tags @> '{3}'::integer[]))
Rows Removed by Filter: 200
Heap Blocks: lossy=113637
-> Bitmap Index Scan on journal_0_0_ordering_idx (cost=0.00..12.03 rows=11261 width=0) (actual time=3.738..3.738 rows=1136640 loops=1)
Index Cond: ((ordering > 1000) AND (ordering <= 3000))
-> Seq Scan on journal_0_1 (cost=0.00..12.28 rows=1 width=597) (actual time=0.008..0.008 rows=0 loops=1)
Filter: ((NOT deleted) AND (tags @> '{3}'::integer[]) AND (ordering > 1000) AND (ordering <= 3000))
Rows Removed by Filter: 1
-> Bitmap Heap Scan on journal_1_0 (cost=12.03..33237.63 rows=1 width=54) (actual time=994.456..994.456 rows=0 loops=1)
Recheck Cond: ((ordering > 1000) AND (ordering <= 3000))
Rows Removed by Index Recheck: 9999800
Filter: ((NOT deleted) AND (tags @> '{3}'::integer[]))
Rows Removed by Filter: 200
Heap Blocks: lossy=113637
-> Bitmap Index Scan on journal_1_0_ordering_idx (cost=0.00..12.03 rows=11261 width=0) (actual time=3.440..3.440 rows=1136640 loops=1)
Index Cond: ((ordering > 1000) AND (ordering <= 3000))
-> Seq Scan on journal_1_1 (cost=0.00..12.28 rows=1 width=597) (actual time=0.002..0.002 rows=0 loops=1)
Filter: ((NOT deleted) AND (tags @> '{3}'::integer[]) AND (ordering > 1000) AND (ordering <= 3000))
-> Bitmap Heap Scan on journal_9_0 (cost=12.03..33237.63 rows=1 width=54) (actual time=1020.481..1020.481 rows=0 loops=1)
Recheck Cond: ((ordering > 1000) AND (ordering <= 3000))
Rows Removed by Index Recheck: 9999800
Filter: ((NOT deleted) AND (tags @> '{3}'::integer[]))
Rows Removed by Filter: 200
Heap Blocks: lossy=113637
-> Bitmap Index Scan on journal_9_0_ordering_idx (cost=0.00..12.03 rows=11261 width=0) (actual time=3.408..3.408 rows=1136640 loops=1)
Index Cond: ((ordering > 1000) AND (ordering <= 3000))
-> Seq Scan on journal_9_1 (cost=0.00..12.28 rows=1 width=597) (actual time=0.003..0.003 rows=0 loops=1)
Filter: ((NOT deleted) AND (tags @> '{3}'::integer[]) AND (ordering > 1000) AND (ordering <= 3000))
Planning Time: 1.107 ms
Execution Time: 9743.521 ms
(107 rows)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment