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?.
2 rows affected
4 rows affected
QUERY PLAN
GroupAggregate (cost=2.08..2.12 rows=1 width=48) (actual time=0.045..0.045 rows=1 loops=1)
  Output: (date_trunc('month'::text, orders.order_date)), sum(orders.amount), count(*)
  Group Key: (date_trunc('month'::text, orders.order_date))
  Buffers: shared hit=2
  -> Sort (cost=2.08..2.09 rows=2 width=15) (actual time=0.034..0.034 rows=2 loops=1)
        Output: (date_trunc('month'::text, orders.order_date)), orders.amount
        Sort Key: (date_trunc('month'::text, orders.order_date))
        Sort Method: quicksort Memory: 25kB
        Buffers: shared hit=2
        -> Nested Loop (cost=0.00..2.07 rows=2 width=15) (actual time=0.024..0.027 rows=2 loops=1)
              Output: date_trunc('month'::text, orders.order_date), orders.amount
              Buffers: shared hit=2
              -> Seq Scan on public.users (cost=0.00..1.02 rows=1 width=8) (actual time=0.012..0.012 rows=1 loops=1)
                    Output: users.user_id, users.first_name, users.last_name
                    Filter: (users.user_id = 2)
                    Rows Removed by Filter: 1
                    Buffers: shared hit=1
              -> Seq Scan on public.orders_3 orders (cost=0.00..1.02 rows=2 width=23) (actual time=0.005..0.006 rows=2 loops=1)
                    Output: orders.order_date, orders.amount, orders.user_id
                    Filter: (orders.user_id = 2)
                    Buffers: shared hit=1
Planning Time: 0.720 ms
  Buffers: shared hit=110 read=4
Execution Time: 0.118 ms