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 |
---|
8997 |
count |
---|
8997 |
QUERY PLAN |
---|
Hash Join (cost=13991.67..21269.92 rows=37400 width=196) (actual time=101.851..323.456 rows=70000 loops=1) |
Hash Cond: (second.first_id = first.id) |
-> Hash Join (cost=13667.64..20847.67 rows=37400 width=160) (actual time=99.280..298.649 rows=70000 loops=1) |
Hash Cond: (third.second_id = second.id) |
-> Hash Join (cost=9331.14..14219.99 rows=37400 width=120) (actual time=67.424..192.355 rows=70000 loops=1) |
Hash Cond: (fourth.third_id = third.id) |
-> Hash Join (cost=4994.64..7958.32 rows=37400 width=80) (actual time=35.754..98.504 rows=70000 loops=1) |
Hash Cond: (fifth.fourth_id = fourth.id) |
-> Bitmap Heap Scan on fifth (cost=658.14..2060.64 rows=37400 width=40) (actual time=4.026..17.148 rows=70000 loops=1) |
Recheck Cond: (id > 30000) |
Heap Blocks: exact=655 |
-> Bitmap Index Scan on fifth_pkey (cost=0.00..648.79 rows=37400 width=0) (actual time=3.948..3.949 rows=70000 loops=1) |
Index Cond: (id > 30000) |
-> Hash (cost=2057.00..2057.00 rows=112200 width=40) (actual time=31.538..31.539 rows=100000 loops=1) |
Buckets: 65536 Batches: 4 Memory Usage: 2296kB |
-> Seq Scan on fourth (cost=0.00..2057.00 rows=112200 width=40) (actual time=0.019..13.785 rows=100000 loops=1) |
-> Hash (cost=2057.00..2057.00 rows=112200 width=40) (actual time=31.607..31.607 rows=100000 loops=1) |
Buckets: 65536 Batches: 4 Memory Usage: 2296kB |
-> Seq Scan on third (cost=0.00..2057.00 rows=112200 width=40) (actual time=0.020..13.969 rows=100000 loops=1) |
-> Hash (cost=2057.00..2057.00 rows=112200 width=40) (actual time=31.780..31.781 rows=100000 loops=1) |
Buckets: 65536 Batches: 4 Memory Usage: 2296kB |
-> Seq Scan on second (cost=0.00..2057.00 rows=112200 width=40) (actual time=0.017..14.041 rows=100000 loops=1) |
-> Hash (cost=190.68..190.68 rows=10668 width=36) (actual time=2.550..2.551 rows=10000 loops=1) |
Buckets: 16384 Batches: 1 Memory Usage: 802kB |
-> Seq Scan on first (cost=0.00..190.68 rows=10668 width=36) (actual time=0.023..1.317 rows=10000 loops=1) |
Planning Time: 0.440 ms |
Execution Time: 326.313 ms |
QUERY PLAN |
---|
Seq Scan on all_json (cost=0.00..2799.68 rows=137 width=36) (actual time=0.038..139.652 rows=8997 loops=1) |
Filter: (data @? '$."second"[*]."third"[*]."fourth"[*]."fifth"[*]."id"?(@ > 30000)'::jsonpath) |
Rows Removed by Filter: 1003 |
Planning Time: 0.092 ms |
Execution Time: 140.443 ms |