BEGIN; BEGIN EXPLAIN (ANALYZE, BUFFERS) select l_shipmode, sum(case when o_orderpriority = '1-URGENT' or o_orderpriority = '2-HIGH' then 1 else 0 end) as high_line_count, sum(case when o_orderpriority <> '1-URGENT' and o_orderpriority <> '2-HIGH' then 1 else 0 end) as low_line_count from orders, lineitem where o_orderkey = l_orderkey and l_shipmode in ('SHIP', 'TRUCK') and l_commitdate < l_receiptdate and l_shipdate < l_commitdate and l_receiptdate >= date '1996-01-01' and l_receiptdate < date '1996-01-01' + interval '1 year' group by l_shipmode order by l_shipmode; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Sort (cost=3059289.98..3059289.98 rows=1 width=27) (actual time=33670.446..33670.446 rows=2 loops=1) Sort Key: lineitem.l_shipmode Sort Method: quicksort Memory: 25kB Buffers: shared hit=881022 read=454806 dirtied=253 written=69 -> HashAggregate (cost=3059289.96..3059289.97 rows=1 width=27) (actual time=33670.394..33670.395 rows=2 loops=1) Group Key: lineitem.l_shipmode Buffers: shared hit=881017 read=454806 dirtied=253 written=69 -> Hash Join (cost=598445.50..3054135.63 rows=294533 width=27) (actual time=9802.465..33352.784 rows=312249 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=881017 read=454806 dirtied=253 written=69 -> Seq Scan on lineitem (cost=0.00..2446485.98 rows=294533 width=15) (actual time=0.097..23245.692 rows=312249 loops=1) Filter: ((l_shipmode = ANY ('{SHIP,TRUCK}'::bpchar[])) AND (l_commitdate < l_receiptdate) AND (l_shipdate < l_commitdate) AND (l_receiptdate >= '1996-01-01'::date) AND (l_receiptdate < '1997-01-01 00:00:00'::timestamp without time zone)) Rows Removed by Filter: 59673289 Buffers: shared hit=716147 read=363113 -> Hash (cost=408509.11..408509.11 rows=15194911 width=20) (actual time=9733.241..9733.241 rows=15000000 loops=1) Buckets: 16777216 Batches: 1 Memory Usage: 892791kB Buffers: shared hit=164867 read=91693 dirtied=253 written=69 -> Seq Scan on orders (cost=0.00..408509.11 rows=15194911 width=20) (actual time=0.012..4621.013 rows=15000000 loops=1) Buffers: shared hit=164867 read=91693 dirtied=253 written=69 Planning time: 2.089 ms Execution time: 33674.631 ms (21 rows) COMMIT; COMMIT