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?.
val val val
80 80 2.5
80 80 2.5
80 80 2.5
80 80 2.5
80 80 2.5
80 80 2.5
SELECT 6
QUERY PLAN
Function Scan on pg_catalog.generate_series b (cost=0.26..0.32 rows=6 width=40) (actual time=0.057..0.059 rows=6 loops=1)
  Output: $0, $1, $2
  Function Call: generate_series(1, 6)
  InitPlan 1 (returns $0)
    -> Limit (cost=0.09..0.09 rows=1 width=12) (actual time=0.007..0.008 rows=1 loops=1)
          Output: val.val, (random())
          -> Sort (cost=0.09..0.10 rows=5 width=12) (actual time=0.007..0.007 rows=1 loops=1)
                Output: val.val, (random())
                Sort Key: (random())
                Sort Method: top-N heapsort Memory: 25kB
                -> Function Scan on pg_catalog.unnest val (cost=0.00..0.07 rows=5 width=12) (actual time=0.003..0.004 rows=5 loops=1)
                      Output: val.val, random()
                      Function Call: unnest('{50,60,80,100,200}'::integer[])
  InitPlan 2 (returns $1)
    -> Limit (cost=0.09..0.09 rows=1 width=12) (actual time=0.027..0.028 rows=1 loops=1)
          Output: val_1.val, (random())
          -> Sort (cost=0.09..0.10 rows=5 width=12) (actual time=0.027..0.027 rows=1 loops=1)
                Output: val_1.val, (random())
                Sort Key: (random())
                Sort Method: top-N heapsort Memory: 25kB
                -> Function Scan on pg_catalog.unnest val_1 (cost=0.00..0.07 rows=5 width=12) (actual time=0.016..0.016 rows=5 loops=1)
                      Output: val_1.val, random()
                      Function Call: unnest('{50,60,80,100,200}'::integer[])
  InitPlan 3 (returns $2)
    -> Limit (cost=0.07..0.08 rows=1 width=40) (actual time=0.018..0.018 rows=1 loops=1)
          Output: val_2.val, (random())
          -> Sort (cost=0.07..0.08 rows=4 width=40) (actual time=0.017..0.017 rows=1 loops=1)
                Output: val_2.val, (random())
                Sort Key: (random())
                Sort Method: top-N heapsort Memory: 25kB
                -> Function Scan on pg_catalog.unnest val_2 (cost=0.00..0.05 rows=4 width=40) (actual time=0.009..0.009 rows=4 loops=1)
                      Output: val_2.val, random()
                      Function Call: unnest('{1.5,1.8,2.1,2.5}'::numeric[])
Planning Time: 0.108 ms
Execution Time: 0.122 ms
EXPLAIN
val val val
80 100 2.5
200 200 1.5
80 100 1.5
80 100 1.8
50 100 1.8
80 80 1.5
SELECT 6
QUERY PLAN
Function Scan on pg_catalog.generate_series b (cost=0.00..2.46 rows=6 width=40) (actual time=0.066..0.121 rows=6 loops=1)
  Output: (SubPlan 1), (SubPlan 2), (SubPlan 3)
  Function Call: generate_series(1, 6)
  SubPlan 1
    -> Limit (cost=0.14..0.14 rows=1 width=12) (actual time=0.005..0.005 rows=1 loops=6)
          Output: val.val, (((random() + (b.n)::double precision) - (b.n)::double precision))
          -> Sort (cost=0.14..0.15 rows=5 width=12) (actual time=0.005..0.005 rows=1 loops=6)
                Output: val.val, (((random() + (b.n)::double precision) - (b.n)::double precision))
                Sort Key: (((random() + (b.n)::double precision) - (b.n)::double precision))
                Sort Method: top-N heapsort Memory: 25kB
                -> Function Scan on pg_catalog.unnest val (cost=0.00..0.12 rows=5 width=12) (actual time=0.002..0.003 rows=5 loops=6)
                      Output: val.val, ((random() + (b.n)::double precision) - (b.n)::double precision)
                      Function Call: unnest('{50,60,80,100,200}'::integer[])
  SubPlan 2
    -> Limit (cost=0.14..0.14 rows=1 width=12) (actual time=0.005..0.005 rows=1 loops=6)
          Output: val_1.val, (((random() + (b.n)::double precision) - (b.n)::double precision))
          -> Sort (cost=0.14..0.15 rows=5 width=12) (actual time=0.005..0.005 rows=1 loops=6)
                Output: val_1.val, (((random() + (b.n)::double precision) - (b.n)::double precision))
                Sort Key: (((random() + (b.n)::double precision) - (b.n)::double precision))
                Sort Method: top-N heapsort Memory: 25kB
                -> Function Scan on pg_catalog.unnest val_1 (cost=0.00..0.12 rows=5 width=12) (actual time=0.002..0.002 rows=5 loops=6)
                      Output: val_1.val, ((random() + (b.n)::double precision) - (b.n)::double precision)
                      Function Call: unnest('{50,60,80,100,200}'::integer[])
  SubPlan 3
    -> Limit (cost=0.11..0.12 rows=1 width=40) (actual time=0.005..0.005 rows=1 loops=6)
          Output: val_2.val, (((random() + (b.n)::double precision) - (b.n)::double precision))
          -> Sort (cost=0.11..0.12 rows=4 width=40) (actual time=0.005..0.005 rows=1 loops=6)
                Output: val_2.val, (((random() + (b.n)::double precision) - (b.n)::double precision))
                Sort Key: (((random() + (b.n)::double precision) - (b.n)::double precision))
                Sort Method: top-N heapsort Memory: 25kB
                -> Function Scan on pg_catalog.unnest val_2 (cost=0.00..0.09 rows=4 width=40) (actual time=0.003..0.003 rows=4 loops=6)
                      Output: val_2.val, ((random() + (b.n)::double precision) - (b.n)::double precision)
                      Function Call: unnest('{1.5,1.8,2.1,2.5}'::numeric[])
Planning Time: 0.080 ms
Execution Time: 0.169 ms
EXPLAIN