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?.
CREATE TABLE
CREATE TABLE
setseed
SELECT 1
INSERT 0 28716
expid iteration value
1 187 0.5
2 242 4.6
2 464 8.7
2 710 6.8
3 635 9.2
5 450 5
5 464 5.9
6 699 0
8 27 7.2
8 467 1.4
8 497 4.9
12 14 6.9
12 112 0.3
12 256 2
12 328 1.4
SELECT 15
DROP TABLE
QUERY PLAN
GroupAggregate (cost=26742.48..28244.98 rows=200 width=36) (actual time=157.406..204.991 rows=60 loops=1)
  Output: measures_1.expid, array_agg(m.value ORDER BY g.i)
  Group Key: measures_1.expid
  -> Sort (cost=26742.48..27242.48 rows=200000 width=12) (actual time=156.936..185.732 rows=48000 loops=1)
        Output: measures_1.expid, m.value, g.i
        Sort Key: measures_1.expid
        Sort Method: quicksort Memory: 3755kB
        -> Hash Left Join (cost=2138.76..5713.34 rows=200000 width=12) (actual time=55.250..124.868 rows=48000 loops=1)
              Output: measures_1.expid, m.value, g.i
              Inner Unique: true
              Hash Cond: ((g.i = m.iteration) AND (measures_1.expid = m.expid))
              -> Nested Loop (cost=1187.16..3711.68 rows=200000 width=8) (actual time=23.129..32.282 rows=48000 loops=1)
                    Output: g.i, measures_1.expid
                    -> Nested Loop (cost=633.36..653.38 rows=1000 width=4) (actual time=5.549..5.821 rows=800 loops=1)
                          Output: g.i
                          -> Aggregate (cost=633.36..633.37 rows=1 width=8) (actual time=5.422..5.424 rows=1 loops=1)
                                Output: min(measures.iteration), max(measures.iteration)
                                -> Seq Scan on public.measures (cost=0.00..474.24 rows=31824 width=4) (actual time=0.019..3.067 rows=28716 loops=1)
                                      Output: measures.expid, measures.iteration, measures.value
                          -> Function Scan on pg_catalog.generate_series g (cost=0.00..10.00 rows=1000 width=4) (actual time=0.120..0.253 rows=800 loops=1)
                                Output: g.i
                                Function Call: generate_series((min(measures.iteration)), (max(measures.iteration)))
                    -> Materialize (cost=553.80..558.80 rows=200 width=4) (actual time=0.022..0.026 rows=60 loops=800)
                          Output: measures_1.expid
                          -> HashAggregate (cost=553.80..555.80 rows=200 width=4) (actual time=17.570..17.585 rows=60 loops=1)
                                Output: measures_1.expid
                                Group Key: measures_1.expid
                                Batches: 1 Memory Usage: 40kB
                                -> Seq Scan on public.measures measures_1 (cost=0.00..474.24 rows=31824 width=4) (actual time=0.018..2.560 rows=28716 loops=1)
                                      Output: measures_1.expid, measures_1.iteration, measures_1.value
              -> Hash (cost=474.24..474.24 rows=31824 width=12) (actual time=31.951..31.952 rows=28716 loops=1)
                    Output: m.value, m.iteration, m.expid
                    Buckets: 32768 Batches: 1 Memory Usage: 1490kB
                    -> Seq Scan on public.measures m (cost=0.00..474.24 rows=31824 width=12) (actual time=0.014..3.870 rows=28716 loops=1)
                          Output: m.value, m.iteration, m.expid
Planning Time: 0.590 ms
Execution Time: 254.830 ms
EXPLAIN
CREATE FUNCTION
QUERY PLAN
Result (cost=0.00..0.26 rows=1 width=4) (actual time=15809.635..15809.635 rows=1 loops=1)
  Output: plpgsql_looped_update()
Planning Time: 0.023 ms
Execution Time: 15809.671 ms
EXPLAIN