Skip to content

Instantly share code, notes, and snippets.

@mkubala
Created July 10, 2020 11:53
Show Gist options
  • Save mkubala/7624131b211cac382ed5e4a9a9129a77 to your computer and use it in GitHub Desktop.
Save mkubala/7624131b211cac382ed5e4a9a9129a77 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=352320.62..352320.67 rows=20 width=83) (actual time=9310.650..9310.683 rows=200 loops=1)
-> Sort (cost=352320.62..352320.67 rows=20 width=83) (actual time=9310.649..9310.664 rows=200 loops=1)
Sort Key: journal_0_0.ordering
Sort Method: quicksort Memory: 53kB
-> Append (cost=12.03..352320.19 rows=20 width=83) (actual time=2834.936..9310.622 rows=200 loops=1)
-> Bitmap Heap Scan on journal_0_0 (cost=12.03..35212.03 rows=1 width=54) (actual time=921.642..921.642 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=103093
-> Bitmap Index Scan on journal_0_0_ordering_idx (cost=0.00..12.03 rows=12407 width=0) (actual time=2.992..2.992 rows=1031680 loops=1)
Index Cond: ((ordering > 1000) AND (ordering <= 3000))
-> Seq Scan on journal_0_1 (cost=0.00..19.98 rows=1 width=113) (actual time=0.010..0.010 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..35212.03 rows=1 width=54) (actual time=945.868..945.868 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=103093
-> Bitmap Index Scan on journal_1_0_ordering_idx (cost=0.00..12.03 rows=12407 width=0) (actual time=2.987..2.987 rows=1031680 loops=1)
Index Cond: ((ordering > 1000) AND (ordering <= 3000))
-> Seq Scan on journal_1_1 (cost=0.00..19.98 rows=1 width=113) (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..35212.03 rows=1 width=54) (actual time=938.431..938.431 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=103093
-> Bitmap Index Scan on journal_9_0_ordering_idx (cost=0.00..12.03 rows=12407 width=0) (actual time=2.981..2.981 rows=1031680 loops=1)
Index Cond: ((ordering > 1000) AND (ordering <= 3000))
-> Seq Scan on journal_9_1 (cost=0.00..19.98 rows=1 width=113) (actual time=0.002..0.002 rows=0 loops=1)
Filter: ((NOT deleted) AND (tags @> '{3}'::integer[]) AND (ordering > 1000) AND (ordering <= 3000))
Planning Time: 1.163 ms
Execution Time: 9311.921 ms
(107 rows)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment