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
CREATE INDEX
QUERY PLAN |
---|
Limit (cost=8.18..8.19 rows=1 width=84) (actual time=0.059..0.060 rows=0 loops=1) |
-> Sort (cost=8.18..8.19 rows=1 width=84) (actual time=0.058..0.059 rows=0 loops=1) |
Sort Key: priority DESC, attempts, creation_time |
Sort Method: quicksort Memory: 25kB |
-> Index Scan using test_table_queue_status_code_idx on test_table (cost=0.15..8.17 rows=1 width=84) (actual time=0.005..0.005 rows=0 loops=1) |
Index Cond: ((queue = 'myqueue'::text) AND (status_code = 'pending'::text)) |
Planning Time: 0.995 ms |
Execution Time: 0.098 ms |
EXPLAIN
QUERY PLAN |
---|
Subquery Scan on "T1" (cost=8.18..8.21 rows=1 width=4) (actual time=0.025..0.026 rows=0 loops=1) |
-> Limit (cost=8.18..8.20 rows=1 width=84) (actual time=0.024..0.025 rows=0 loops=1) |
-> Subquery Scan on "T1_1" (cost=8.18..8.20 rows=1 width=84) (actual time=0.024..0.024 rows=0 loops=1) |
-> Sort (cost=8.18..8.19 rows=1 width=84) (actual time=0.023..0.024 rows=0 loops=1) |
Sort Key: "T1_2".priority DESC, "T1_2".attempts, "T1_2".creation_time |
Sort Method: quicksort Memory: 25kB |
-> Index Scan using test_table_queue_status_code_idx on test_table "T1_2" (cost=0.15..8.17 rows=1 width=84) (actual time=0.013..0.014 rows=0 loops=1) |
Index Cond: ((queue = 'myqueue'::text) AND (status_code = 'pending'::text)) |
Planning Time: 0.311 ms |
Execution Time: 0.079 ms |
EXPLAIN