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?.
SELECT 100000
CREATE INDEX
CREATE INDEX
VACUUM
PREPARE
QUERY PLAN
Limit (cost=54.75..109.20 rows=100 width=28) (actual time=0.565..1.629 rows=100 loops=1)
  Buffers: shared hit=1067
  -> Index Scan Backward using tx_dat on transactions (cost=0.29..5440.29 rows=9990 width=28) (actual time=0.024..1.609 rows=200 loops=1)
        Filter: ((user_id >= 1) AND (user_id <= 10))
        Rows Removed by Filter: 1823
        Buffers: shared hit=1067
Planning:
  Buffers: shared hit=35
Planning Time: 2.211 ms
Execution Time: 1.873 ms
EXPLAIN
DROP INDEX
CREATE INDEX
VACUUM
QUERY PLAN
Limit (cost=44.99..89.68 rows=100 width=28) (actual time=0.170..0.312 rows=100 loops=1)
  Buffers: shared hit=207
  -> Index Scan Backward using tx_dat_usr on transactions (cost=0.29..4533.64 rows=10143 width=28) (actual time=0.017..0.297 rows=200 loops=1)
        Index Cond: ((user_id >= 1) AND (user_id <= 10))
        Buffers: shared hit=207
Planning:
  Buffers: shared hit=31
Planning Time: 0.511 ms
Execution Time: 0.336 ms
EXPLAIN