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 396
ANALYZE
count count
396 8
SELECT 1
PREPARE
QUERY PLAN
Aggregate (cost=6.98..6.99 rows=1 width=8) (actual time=0.041..0.042 rows=1 loops=1)
  Output: count(*)
  Buffers: shared hit=2
  -> Seq Scan on public.demo (cost=0.00..6.95 rows=11 width=0) (actual time=0.011..0.038 rows=11 loops=1)
        Output: n
        Filter: (demo.n = 1)
        Rows Removed by Filter: 385
        Buffers: shared hit=2
Planning Time: 0.087 ms
Execution Time: 0.066 ms
EXPLAIN
QUERY PLAN
Aggregate (cost=7.00..7.01 rows=1 width=8) (actual time=0.042..0.043 rows=1 loops=1)
  Output: count(*)
  Buffers: shared hit=2
  -> Seq Scan on public.demo (cost=0.00..6.95 rows=22 width=0) (actual time=0.013..0.039 rows=22 loops=1)
        Output: n
        Filter: (demo.n = 2)
        Rows Removed by Filter: 374
        Buffers: shared hit=2
Planning Time: 0.045 ms
Execution Time: 0.057 ms
EXPLAIN
QUERY PLAN
Aggregate (cost=7.03..7.04 rows=1 width=8) (actual time=0.043..0.044 rows=1 loops=1)
  Output: count(*)
  Buffers: shared hit=2
  -> Seq Scan on public.demo (cost=0.00..6.95 rows=33 width=0) (actual time=0.014..0.039 rows=33 loops=1)
        Output: n
        Filter: (demo.n = 3)
        Rows Removed by Filter: 363
        Buffers: shared hit=2
Planning Time: 0.043 ms
Execution Time: 0.058 ms
EXPLAIN
QUERY PLAN
Aggregate (cost=7.06..7.07 rows=1 width=8) (actual time=0.044..0.045 rows=1 loops=1)
  Output: count(*)
  Buffers: shared hit=2
  -> Seq Scan on public.demo (cost=0.00..6.95 rows=44 width=0) (actual time=0.015..0.039 rows=44 loops=1)
        Output: n
        Filter: (demo.n = 4)
        Rows Removed by Filter: 352
        Buffers: shared hit=2
Planning Time: 0.042 ms
Execution Time: 0.059 ms
EXPLAIN
QUERY PLAN
Aggregate (cost=7.09..7.10 rows=1 width=8) (actual time=0.045..0.046 rows=1 loops=1)
  Output: count(*)
  Buffers: shared hit=2
  -> Seq Scan on public.demo (cost=0.00..6.95 rows=55 width=0) (actual time=0.018..0.040 rows=55 loops=1)
        Output: n
        Filter: (demo.n = 5)
        Rows Removed by Filter: 341
        Buffers: shared hit=2
Planning Time: 0.042 ms
Execution Time: 0.060 ms
EXPLAIN
QUERY PLAN
Aggregate (cost=7.08..7.08 rows=1 width=8) (actual time=0.049..0.050 rows=1 loops=1)
  Output: count(*)
  Buffers: shared hit=2
  -> Seq Scan on public.demo (cost=0.00..6.95 rows=50 width=0) (actual time=0.022..0.043 rows=66 loops=1)
        Output: n
        Filter: (demo.n = $1)
        Rows Removed by Filter: 330
        Buffers: shared hit=2
Planning Time: 0.041 ms
Execution Time: 0.064 ms
EXPLAIN
QUERY PLAN
Aggregate (cost=7.08..7.08 rows=1 width=8) (actual time=0.050..0.051 rows=1 loops=1)
  Output: count(*)
  Buffers: shared hit=2
  -> Seq Scan on public.demo (cost=0.00..6.95 rows=50 width=0) (actual time=0.030..0.043 rows=77 loops=1)
        Output: n
        Filter: (demo.n = $1)
        Rows Removed by Filter: 319
        Buffers: shared hit=2
Planning Time: 0.006 ms
Execution Time: 0.065 ms
EXPLAIN
QUERY PLAN
Aggregate (cost=7.08..7.08 rows=1 width=8) (actual time=0.075..0.075 rows=1 loops=1)
  Output: count(*)
  Buffers: shared hit=2
  -> Seq Scan on public.demo (cost=0.00..6.95 rows=50 width=0) (actual time=0.057..0.067 rows=88 loops=1)
        Output: n
        Filter: (demo.n = $1)
        Rows Removed by Filter: 308
        Buffers: shared hit=2
Planning Time: 0.006 ms
Execution Time: 0.089 ms
EXPLAIN
QUERY PLAN
Aggregate (cost=7.08..7.08 rows=1 width=8) (actual time=0.041..0.041 rows=1 loops=1)
  Output: count(*)
  Buffers: shared hit=2
  -> Seq Scan on public.demo (cost=0.00..6.95 rows=50 width=0) (actual time=0.039..0.039 rows=0 loops=1)
        Output: n
        Filter: (demo.n = $1)
        Rows Removed by Filter: 396
        Buffers: shared hit=2
Planning Time: 0.006 ms
Execution Time: 0.055 ms
EXPLAIN
count count avg rows per value
396 8 49.5000000000000000
SELECT 1