Skip to content

Instantly share code, notes, and snippets.

@mkubala
Created July 10, 2020 11:56
Show Gist options
  • Save mkubala/3f85ccdb6def29ec7b27ed891ffc9c0c to your computer and use it in GitHub Desktop.
Save mkubala/3f85ccdb6def29ec7b27ed891ffc9c0c 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=41918.26..41918.31 rows=20 width=83) (actual time=911.388..911.421 rows=200 loops=1)
-> Sort (cost=41918.26..41918.31 rows=20 width=83) (actual time=911.387..911.402 rows=200 loops=1)
Sort Key: journal_0_0.ordering
Sort Method: quicksort Memory: 53kB
-> Append (cost=483.28..41917.83 rows=20 width=83) (actual time=13.268..911.356 rows=200 loops=1)
-> Bitmap Heap Scan on journal_0_0 (cost=483.28..727.81 rows=1 width=54) (actual time=3.420..3.420 rows=0 loops=1)
Recheck Cond: ((ordering > 1000) AND (ordering <= 3000) AND (tags @> '{3}'::integer[]))
Rows Removed by Index Recheck: 97
Filter: (NOT deleted)
Heap Blocks: lossy=1
-> BitmapAnd (cost=483.28..483.28 rows=62 width=0) (actual time=3.401..3.401 rows=0 loops=1)
-> Bitmap Index Scan on journal_0_0_ordering_idx (cost=0.00..12.03 rows=12407 width=0) (actual time=2.976..2.976 rows=1031680 loops=1)
Index Cond: ((ordering > 1000) AND (ordering <= 3000))
-> Bitmap Index Scan on journal_0_0_tags_idx (cost=0.00..471.00 rows=50000 width=0) (actual time=0.010..0.010 rows=1 loops=1)
Index Cond: (tags @> '{3}'::integer[])
-> Bitmap Heap Scan on journal_0_1 (cost=12.02..19.14 rows=1 width=113) (actual time=0.005..0.005 rows=0 loops=1)
Recheck Cond: (tags @> '{3}'::integer[])
Filter: ((NOT deleted) AND (ordering > 1000) AND (ordering <= 3000))
-> Bitmap Index Scan on journal_0_1_tags_idx (cost=0.00..12.02 rows=3 width=0) (actual time=0.004..0.004 rows=0 loops=1)
Index Cond: (tags @> '{3}'::integer[])
-> Bitmap Heap Scan on journal_1_0 (cost=483.28..727.80 rows=1 width=54) (actual time=3.396..3.396 rows=0 loops=1)
Recheck Cond: ((ordering > 1000) AND (ordering <= 3000) AND (tags @> '{3}'::integer[]))
Rows Removed by Index Recheck: 97
Filter: (NOT deleted)
Heap Blocks: lossy=1
-> BitmapAnd (cost=483.28..483.28 rows=62 width=0) (actual time=3.381..3.381 rows=0 loops=1)
-> Bitmap Index Scan on journal_1_0_ordering_idx (cost=0.00..12.03 rows=12407 width=0) (actual time=2.959..2.959 rows=1031680 loops=1)
Index Cond: ((ordering > 1000) AND (ordering <= 3000))
-> Bitmap Index Scan on journal_1_0_tags_idx (cost=0.00..471.00 rows=50000 width=0) (actual time=0.007..0.007 rows=1 loops=1)
Index Cond: (tags @> '{3}'::integer[])
-> Bitmap Heap Scan on journal_1_1 (cost=8.02..15.14 rows=1 width=113) (actual time=0.004..0.004 rows=0 loops=1)
Recheck Cond: (tags @> '{3}'::integer[])
Filter: ((NOT deleted) AND (ordering > 1000) AND (ordering <= 3000))
-> Bitmap Index Scan on journal_1_1_tags_idx (cost=0.00..8.02 rows=3 width=0) (actual time=0.003..0.003 rows=0 loops=1)
Index Cond: (tags @> '{3}'::integer[])
-> Bitmap Heap Scan on journal_9_0 (cost=483.28..727.80 rows=1 width=54) (actual time=3.416..3.416 rows=0 loops=1)
Recheck Cond: ((ordering > 1000) AND (ordering <= 3000) AND (tags @> '{3}'::integer[]))
Rows Removed by Index Recheck: 97
Filter: (NOT deleted)
Heap Blocks: lossy=1
-> BitmapAnd (cost=483.28..483.28 rows=62 width=0) (actual time=3.402..3.402 rows=0 loops=1)
-> Bitmap Index Scan on journal_9_0_ordering_idx (cost=0.00..12.03 rows=12407 width=0) (actual time=2.984..2.984 rows=1031680 loops=1)
Index Cond: ((ordering > 1000) AND (ordering <= 3000))
-> Bitmap Index Scan on journal_9_0_tags_idx (cost=0.00..471.00 rows=50000 width=0) (actual time=0.006..0.006 rows=1 loops=1)
Index Cond: (tags @> '{3}'::integer[])
-> Bitmap Heap Scan on journal_9_1 (cost=8.02..15.14 rows=1 width=113) (actual time=0.004..0.004 rows=0 loops=1)
Recheck Cond: (tags @> '{3}'::integer[])
Filter: ((NOT deleted) AND (ordering > 1000) AND (ordering <= 3000))
-> Bitmap Index Scan on journal_9_1_tags_idx (cost=0.00..8.02 rows=3 width=0) (actual time=0.003..0.003 rows=0 loops=1)
Index Cond: (tags @> '{3}'::integer[])
Planning Time: 1.254 ms
Execution Time: 911.704 ms
(154 rows)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment