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?.
version
PostgreSQL 13.4 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 8.4.1 20200928 (Red Hat 8.4.1-1), 64-bit
1 rows affected
10 rows affected
100000 rows affected
100000 rows affected
249790 rows affected
QUERY PLAN
Subquery Scan on supervisor_agenda (cost=10912.75..11824.31 rows=3 width=177) (actual time=158.094..158.099 rows=0 loops=1)
  Filter: (supervisor_agenda.scheduled_activity_id = '00000000-0000-0000-0000-000000000000'::uuid)
  Rows Removed by Filter: 22646
  -> WindowAgg (cost=10912.75..11539.45 rows=22789 width=177) (actual time=131.609..156.511 rows=22646 loops=1)
        -> Sort (cost=10912.75..10969.72 rows=22789 width=97) (actual time=131.590..133.341 rows=22646 loops=1)
              Sort Key: sch.planned_start
              Sort Method: quicksort Memory: 3770kB
              -> Hash Join (cost=6326.39..9263.28 rows=22789 width=97) (actual time=84.010..122.593 rows=22646 loops=1)
                    Hash Cond: (act.uuid = sch.activity_planning_id)
                    -> Seq Scan on activity_planning act (cost=0.00..2334.00 rows=100000 width=49) (actual time=0.014..16.575 rows=100000 loops=1)
                    -> Hash (cost=6041.52..6041.52 rows=22789 width=80) (actual time=83.961..83.965 rows=22646 loops=1)
                          Buckets: 32768 Batches: 1 Memory Usage: 2733kB
                          -> Hash Join (cost=3157.63..6041.52 rows=22789 width=80) (actual time=39.215..75.245 rows=22646 loops=1)
                                Hash Cond: (sch.uuid = su.scheduled_activity_id)
                                -> Seq Scan on scheduled_activity sch (cost=0.00..2031.00 rows=100000 width=48) (actual time=0.015..14.688 rows=100000 loops=1)
                                -> Hash (cost=2872.77..2872.77 rows=22789 width=48) (actual time=39.164..39.166 rows=22646 loops=1)
                                      Buckets: 32768 Batches: 1 Memory Usage: 2026kB
                                      -> Bitmap Heap Scan on supervised_activity su (cost=252.91..2872.77 rows=22789 width=48) (actual time=1.265..30.489 rows=22646 loops=1)
                                            Recheck Cond: (supervisor_id = '00000000-0000-0000-0000-000000000000'::uuid)
                                            Heap Blocks: exact=2335
                                            -> Bitmap Index Scan on idx_supervised_activity_supervisor (cost=0.00..247.21 rows=22789 width=0) (actual time=0.999..0.999 rows=22646 loops=1)
                                                  Index Cond: (supervisor_id = '00000000-0000-0000-0000-000000000000'::uuid)
Planning Time: 1.526 ms
Execution Time: 158.609 ms
QUERY PLAN
WindowAgg (cost=33.06..33.09 rows=1 width=177) (actual time=0.028..0.029 rows=0 loops=1)
  -> Sort (cost=33.06..33.06 rows=1 width=97) (actual time=0.027..0.028 rows=0 loops=1)
        Sort Key: sch.planned_start
        Sort Method: quicksort Memory: 25kB
        -> Nested Loop (cost=5.28..33.05 rows=1 width=97) (actual time=0.024..0.025 rows=0 loops=1)
              -> Nested Loop (cost=4.86..24.61 rows=1 width=80) (actual time=0.023..0.024 rows=0 loops=1)
                    -> Bitmap Heap Scan on supervised_activity su (cost=4.44..16.17 rows=1 width=48) (actual time=0.023..0.023 rows=0 loops=1)
                          Recheck Cond: (scheduled_activity_id = '00000000-0000-0000-0000-000000000000'::uuid)
                          Filter: (supervisor_id = '00000000-0000-0000-0000-000000000000'::uuid)
                          -> Bitmap Index Scan on idx_supervised_activity_scheduled_activity (cost=0.00..4.44 rows=3 width=0) (actual time=0.021..0.021 rows=0 loops=1)
                                Index Cond: (scheduled_activity_id = '00000000-0000-0000-0000-000000000000'::uuid)
                    -> Index Scan using pkey_scheduled_activity on scheduled_activity sch (cost=0.42..8.44 rows=1 width=48) (never executed)
                          Index Cond: (uuid = '00000000-0000-0000-0000-000000000000'::uuid)
              -> Index Scan using pkey_activity_planning on activity_planning act (cost=0.42..8.44 rows=1 width=49) (never executed)
                    Index Cond: (uuid = sch.activity_planning_id)
Planning Time: 0.445 ms
Execution Time: 0.076 ms