By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
Help with an interesting Postgres question: Why isn't an Index Only Scan used on a partition accessed via the parent table?.
10000 rows affected
100000 rows affected
100000 rows affected
100000 rows affected
100000 rows affected
10000 rows affected
count |
---|
7819 |
count |
---|
8959 |
QUERY PLAN |
---|
Sort (cost=31016.75..31139.56 rows=49123 width=234) (actual time=413.205..437.987 rows=35134 loops=1) |
Sort Key: first.title |
Sort Method: external merge Disk: 8824kB |
-> Hash Join (cost=12112.92..21645.06 rows=49123 width=234) (actual time=114.659..322.080 rows=35134 loops=1) |
Hash Cond: (second.first_id = first.id) |
-> Hash Join (cost=11803.92..21207.06 rows=49123 width=164) (actual time=111.393..303.192 rows=35134 loops=1) |
Hash Cond: (third.second_id = second.id) |
-> Hash Join (cost=7739.93..14311.11 rows=49123 width=123) (actual time=72.293..206.748 rows=35134 loops=1) |
Hash Cond: (fourth.third_id = third.id) |
-> Hash Join (cost=3675.93..7895.16 rows=49123 width=82) (actual time=35.712..110.706 rows=35134 loops=1) |
Hash Cond: (fifth.fourth_id = fourth.id) |
-> Seq Scan on fifth (cost=0.00..2185.00 rows=70182 width=41) (actual time=4.057..26.182 rows=70000 loops=1) |
Filter: (id > 30000) |
Rows Removed by Filter: 30000 |
-> Hash (cost=2185.00..2185.00 rows=69994 width=41) (actual time=31.504..31.505 rows=70000 loops=1) |
Buckets: 65536 Batches: 2 Memory Usage: 3004kB |
-> Seq Scan on fourth (cost=0.00..2185.00 rows=69994 width=41) (actual time=4.012..17.651 rows=70000 loops=1) |
Filter: (id > 30000) |
Rows Removed by Filter: 30000 |
-> Hash (cost=1935.00..1935.00 rows=100000 width=41) (actual time=36.447..36.448 rows=100000 loops=1) |
Buckets: 65536 Batches: 4 Memory Usage: 2296kB |
-> Seq Scan on third (cost=0.00..1935.00 rows=100000 width=41) (actual time=0.015..15.515 rows=100000 loops=1) |
-> Hash (cost=1935.00..1935.00 rows=100000 width=41) (actual time=37.045..37.045 rows=100000 loops=1) |
Buckets: 65536 Batches: 4 Memory Usage: 2296kB |
-> Seq Scan on second (cost=0.00..1935.00 rows=100000 width=41) (actual time=0.013..15.887 rows=100000 loops=1) |
-> Hash (cost=184.00..184.00 rows=10000 width=37) (actual time=3.244..3.245 rows=10000 loops=1) |
Buckets: 16384 Batches: 1 Memory Usage: 802kB |
-> Seq Scan on first (cost=0.00..184.00 rows=10000 width=37) (actual time=0.012..1.753 rows=10000 loops=1) |
Planning Time: 2.734 ms |
Execution Time: 445.302 ms |
QUERY PLAN |
---|
Sort (cost=3201.32..3201.33 rows=1 width=68) (actual time=514.285..526.707 rows=8959 loops=1) |
Sort Key: ((data -> 'title'::text)) |
Sort Method: external merge Disk: 7168kB |
-> Seq Scan on all_json (cost=0.00..3201.31 rows=1 width=68) (actual time=0.121..454.346 rows=8959 loops=1) |
Filter: ((data @? '$."second"[*]."third"[*]."fourth"[*]."fifth"[*]."id"?(@ > 30000)'::jsonpath) AND (data @? '$."second"[*]."third"[*]."fourth"[*]."id"?(@ > 30000)'::jsonpath)) |
Rows Removed by Filter: 1041 |
Planning Time: 0.171 ms |
Execution Time: 528.293 ms |