add batch remove batch split batch comment selection show hidden batches hide batch highlight batch
db<>fiddle
donate feedback about
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?.
DROP TABLE
CREATE TABLE
INSERT 0 2000000
ANALYZE
CREATE INDEX
QUERY PLAN
Limit (cost=8.46..8.46 rows=1 width=4) (actual time=0.032..0.033 rows=0 loops=1)
  -> Sort (cost=8.46..8.46 rows=1 width=4) (actual time=0.028..0.029 rows=0 loops=1)
        Sort Key: order_id
        Sort Method: quicksort Memory: 25kB
        -> Index Only Scan using orders_test_shipping_date_order_id_idx on orders_test (cost=0.43..8.45 rows=1 width=4) (actual time=0.015..0.015 rows=0 loops=1)
              Index Cond: ((shipping_date >= '2022-05-01'::date) AND (shipping_date <= '2022-05-01'::date))
              Heap Fetches: 0
Planning Time: 0.679 ms
Execution Time: 0.241 ms
EXPLAIN
INSERT 0 100000
ANALYZE
QUERY PLAN
Limit (cost=0.43..38.19 rows=50 width=4) (actual time=338.588..338.608 rows=50 loops=1)
  -> Index Scan using orders_test_pkey on orders_test (cost=0.43..74336.43 rows=98420 width=4) (actual time=338.586..338.602 rows=50 loops=1)
        Filter: ((shipping_date >= '2022-05-01'::date) AND (shipping_date <= '2022-05-01'::date))
        Rows Removed by Filter: 2000000
Planning Time: 0.332 ms
Execution Time: 338.629 ms
EXPLAIN