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?.
100000 rows affected
QUERY PLAN
WindowAgg (cost=0.29..6518.29 rows=100000 width=16) (actual rows=100000 loops=1)
  -> Index Scan using idx_foo on foo (cost=0.29..4768.29 rows=100000 width=12) (actual rows=100000 loops=1)
Planning time: 1.250 ms
Execution time: 359.243 ms
QUERY PLAN
WindowAgg (cost=0.29..10018.29 rows=100000 width=28) (actual rows=100000 loops=1)
  -> Subquery Scan on dt (cost=0.29..7518.29 rows=100000 width=20) (actual rows=100000 loops=1)
        -> WindowAgg (cost=0.29..6518.29 rows=100000 width=20) (actual rows=100000 loops=1)
              -> Index Scan using idx_foo on foo (cost=0.29..4768.29 rows=100000 width=12) (actual rows=100000 loops=1)
Planning time: 0.192 ms
Execution time: 147.832 ms
QUERY PLAN
Function Scan on bar (cost=0.25..10.25 rows=1000 width=16) (actual rows=100000 loops=1)
Planning time: 0.062 ms
Execution time: 171.275 ms
QUERY PLAN
WindowAgg (cost=0.29..9768.29 rows=100000 width=16) (actual rows=100000 loops=1)
  -> Subquery Scan on sub (cost=0.29..7518.29 rows=100000 width=16) (actual rows=100000 loops=1)
        -> WindowAgg (cost=0.29..6518.29 rows=100000 width=20) (actual rows=100000 loops=1)
              -> Index Scan using idx_foo on foo (cost=0.29..4768.29 rows=100000 width=12) (actual rows=100000 loops=1)
Planning time: 0.116 ms
Execution time: 133.168 ms
QUERY PLAN
Function Scan on f_special_rolling_sum (cost=0.25..10.25 rows=1000 width=12) (actual rows=100000 loops=1)
Planning time: 0.034 ms
Execution time: 140.498 ms
QUERY PLAN
WindowAgg (cost=0.42..4802.42 rows=100000 width=12) (actual rows=100000 loops=1)
  -> Index Only Scan using idx_foo_covering on foo (cost=0.42..3052.42 rows=100000 width=12) (actual rows=100000 loops=1)
        Heap Fetches: 0
Planning time: 0.216 ms
Execution time: 200.740 ms
QUERY PLAN
Function Scan on bar (cost=0.25..10.25 rows=1000 width=16) (actual rows=100000 loops=1)
Planning time: 0.037 ms
Execution time: 393.593 ms
QUERY PLAN
Function Scan on f_special_rolling_sum (cost=0.25..10.25 rows=1000 width=12) (actual rows=100000 loops=1)
Planning time: 0.034 ms
Execution time: 105.216 ms
QUERY PLAN
WindowAgg (cost=0.42..8302.42 rows=100000 width=28) (actual rows=100000 loops=1)
  -> Subquery Scan on dt (cost=0.42..5802.42 rows=100000 width=20) (actual rows=100000 loops=1)
        -> WindowAgg (cost=0.42..4802.42 rows=100000 width=20) (actual rows=100000 loops=1)
              -> Index Only Scan using idx_foo_covering on foo (cost=0.42..3052.42 rows=100000 width=12) (actual rows=100000 loops=1)
                    Heap Fetches: 0
Planning time: 0.128 ms
Execution time: 109.008 ms
QUERY PLAN
WindowAgg (cost=0.42..8052.42 rows=100000 width=16) (actual rows=100000 loops=1)
  -> Subquery Scan on sub (cost=0.42..5802.42 rows=100000 width=16) (actual rows=100000 loops=1)
        -> WindowAgg (cost=0.42..4802.42 rows=100000 width=20) (actual rows=100000 loops=1)
              -> Index Only Scan using idx_foo_covering on foo (cost=0.42..3052.42 rows=100000 width=12) (actual rows=100000 loops=1)
                    Heap Fetches: 0
Planning time: 0.124 ms
Execution time: 87.903 ms