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?.
CREATE TABLE
INSERT 0 100000
CREATE INDEX
VACUUM
QUERY PLAN |
---|
Limit (cost=96.33..96.36 rows=10 width=20) (actual time=0.186..0.191 rows=10 loops=1) |
Buffers: shared hit=51 read=3 |
-> Sort (cost=96.33..96.46 rows=52 width=20) (actual time=0.178..0.180 rows=10 loops=1) |
Sort Key: refreshed_utc |
Sort Method: top-N heapsort Memory: 25kB |
Buffers: shared hit=51 read=3 |
-> Index Scan using tbl_foo_idx on tbl (cost=0.42..95.21 rows=52 width=20) (actual time=0.065..0.139 rows=51 loops=1) |
Index Cond: ((purged_utc IS NULL) AND (refreshed_utc < '2021-07-11 00:00:00'::timestamp without time zone)) |
Buffers: shared hit=51 read=3 |
Planning: |
Buffers: shared hit=34 read=1 |
Planning Time: 0.874 ms |
Execution Time: 0.259 ms |
EXPLAIN
QUERY PLAN |
---|
Limit (cost=0.42..8.44 rows=1 width=20) (actual time=0.045..0.045 rows=0 loops=1) |
Buffers: shared hit=1 read=2 |
-> Index Scan using tbl_foo_idx on tbl (cost=0.42..8.44 rows=1 width=20) (actual time=0.044..0.044 rows=0 loops=1) |
Index Cond: ((purged_utc = '2021-07-11 00:00:00'::timestamp without time zone) AND (refreshed_utc < '2021-07-11 00:00:00'::timestamp without time zone)) |
Buffers: shared hit=1 read=2 |
Planning Time: 0.125 ms |
Execution Time: 0.067 ms |
EXPLAIN