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?.
setseed
SELECT 1
CREATE TABLE
CREATE TABLE
CREATE TABLE
INSERT 0 2000
INSERT 0 40000
INSERT 0 20000
PREPARE
QUERY PLAN
Incremental Sort (cost=475713.66..475735.06 rows=200 width=40) (actual time=2924.873..2924.878 rows=5 loops=1)
  Output: r.acceptance_status, (count(*))
  Sort Key: r.acceptance_status, (count(*))
  Presorted Key: r.acceptance_status
  Full-sort Groups: 1 Sort Method: quicksort Average Memory: 25kB Peak Memory: 25kB
  -> GroupAggregate (cost=475713.59..475726.06 rows=200 width=40) (actual time=2924.590..2924.791 rows=5 loops=1)
        Output: r.acceptance_status, count(*)
        Group Key: r.acceptance_status
        -> Sort (cost=475713.59..475717.08 rows=1397 width=32) (actual time=2924.361..2924.463 rows=2000 loops=1)
              Output: r.acceptance_status
              Sort Key: r.acceptance_status
              Sort Method: quicksort Memory: 86kB
              -> Nested Loop Left Join (cost=0.00..475640.60 rows=1397 width=32) (actual time=34.960..2923.082 rows=2000 loops=1)
                    Output: r.acceptance_status
                    -> Seq Scan on public.route r (cost=0.00..24.97 rows=1397 width=36) (actual time=0.023..0.466 rows=2000 loops=1)
                          Output: r.route_id, r.acceptance_status
                    -> GroupAggregate (cost=0.00..340.44 rows=1 width=36) (actual time=1.460..1.460 rows=1 loops=2000)
                          Output: rts.route_id, NULL::integer[]
                          -> Seq Scan on public.route_to_shipment rts (cost=0.00..340.43 rows=101 width=4) (actual time=0.156..1.457 rows=10 loops=2000)
                                Output: rts.shipment_id, rts.route_id
                                Filter: (rts.route_id = r.route_id)
                                Rows Removed by Filter: 19990
Planning Time: 0.528 ms
JIT:
  Functions: 11
  Options: Inlining false, Optimization false, Expressions true, Deforming true
  Timing: Generation 1.087 ms, Inlining 0.000 ms, Optimization 2.122 ms, Emission 30.935 ms, Total 34.144 ms
Execution Time: 3143.852 ms
EXPLAIN
acceptance_status count
accepted 502
pending 468
prep 254
rejected 270
sent 506
SELECT 5