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 ('REG AIR', 'SHIP') and l_commitdate < l_receiptdate and l_shipdate < l_commitdate and l_receiptdate >= date '1995-01-01' and l_receiptdate < date '1995-01-01' + interval '1 year' group by l_shipmode order by l_shipmode; QUERY PLAN ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Sort (cost=990914.90..990914.91 rows=1 width=27) (actual time=26618.314..26618.315 rows=2 loops=1) Sort Key: lineitem.l_shipmode Sort Method: quicksort Memory: 25kB Buffers: shared hit=799240 read=570545 dirtied=57 written=663 -> HashAggregate (cost=990914.88..990914.89 rows=1 width=27) (actual time=26618.227..26618.228 rows=2 loops=1) Group Key: lineitem.l_shipmode Buffers: shared hit=799235 read=570545 dirtied=57 written=663 -> Hash Join (cost=597855.79..985786.68 rows=293040 width=27) (actual time=11984.466..26268.333 rows=312083 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=799235 read=570545 dirtied=57 written=663 -> Index Scan using lineitem_l_orderkey_idx_part2 on lineitem (cost=0.43..378773.82 rows=293040 width=15) (actual time=0.193..13941.127 rows=312083 loops=1) Filter: ((l_shipmode = ANY ('{"REG AIR",SHIP}'::bpchar[])) AND (l_receiptdate >= '1995-01-01'::date) AND (l_receiptdate < '1996-01-01 00:00:00'::timestamp without time zone)) Rows Removed by Filter: 6884443 Buffers: shared hit=596494 read=516976 dirtied=57 written=612 -> Hash (cost=408106.27..408106.27 rows=15179927 width=20) (actual time=11835.855..11835.855 rows=15015000 loops=1) Buckets: 16777216 Batches: 1 Memory Usage: 893553kB Buffers: shared hit=202738 read=53569 written=51 -> Seq Scan on orders (cost=0.00..408106.27 rows=15179927 width=20) (actual time=0.025..5951.663 rows=15015000 loops=1) Buffers: shared hit=202738 read=53569 written=51 Planning time: 5.039 ms Execution time: 26637.605 ms (21 rows) COMMIT; COMMIT