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=26740.47..28242.97 rows=200 width=36) (actual time=79.905..90.117 rows=60 loops=1)
  Output: measures_1.expid, array_agg(m.value ORDER BY g.iteration)
  Group Key: measures_1.expid
  -> Sort (cost=26740.47..27240.47 rows=200000 width=12) (actual time=79.688..82.897 rows=48000 loops=1)
        Output: measures_1.expid, m.value, g.iteration
        Sort Key: measures_1.expid, g.iteration
        Sort Method: quicksort Memory: 3261kB
        -> Hash Left Join (cost=2138.76..5711.33 rows=200000 width=12) (actual time=23.440..45.293 rows=48000 loops=1)
              Output: measures_1.expid, m.value, g.iteration
              Inner Unique: true
              Hash Cond: ((g.iteration = m.iteration) AND (measures_1.expid = m.expid))
              -> Nested Loop (cost=1187.16..3709.67 rows=200000 width=8) (actual time=12.184..21.588 rows=48000 loops=1)
                    Output: g.iteration, measures_1.expid
                    -> Nested Loop (cost=633.36..653.37 rows=1000 width=4) (actual time=5.480..5.700 rows=800 loops=1)
                          Output: g.iteration
                          -> Aggregate (cost=633.36..633.37 rows=1 width=8) (actual time=5.353..5.354 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.012..2.727 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.124..0.227 rows=800 loops=1)
                                Output: g.iteration
                                Function Call: generate_series((min(measures.iteration)), (max(measures.iteration)))
                    -> Materialize (cost=553.80..556.80 rows=200 width=4) (actual time=0.008..0.012 rows=60 loops=800)
                          Output: measures_1.expid
                          -> HashAggregate (cost=553.80..555.80 rows=200 width=4) (actual time=6.691..6.702 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.007..2.309 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=10.881..10.882 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.008..3.698 rows=28716 loops=1)
                          Output: m.value, m.iteration, m.expid
Planning Time: 1.077 ms
Execution Time: 94.321 ms
EXPLAIN
CREATE FUNCTION
server closed the connection unexpectedly
	This probably means the server terminated abnormally
	before or while processing the request.