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 ('TRUCK', 'FOB') 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=990004.24..990004.25 rows=1 width=27) (actual time=38109.824..38109.824 rows=2 loops=1) Sort Key: lineitem.l_shipmode Sort Method: quicksort Memory: 25kB Buffers: shared hit=987912 read=381280 dirtied=1132 written=319 -> HashAggregate (cost=990004.22..990004.23 rows=1 width=27) (actual time=38109.671..38109.672 rows=2 loops=1) Buffers: shared hit=987907 read=381280 dirtied=1132 written=319 -> Hash Join (cost=596675.08..984898.25 rows=291770 width=27) (actual time=15359.698..37471.082 rows=312150 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=987907 read=381280 dirtied=1132 written=319 -> Index Scan using lineitem_l_orderkey_idx_part2 on lineitem (cost=0.00..379105.36 rows=291770 width=15) (actual time=0.191..20832.543 rows=312150 loops=1) Filter: ((l_shipmode = ANY ('{TRUCK,FOB}'::bpchar[])) AND (l_receiptdate >= '1996-01-01'::date) AND (l_receiptdate < '1997-01-01 00:00:00'::timestamp without time zone)) Rows Removed by Filter: 6877220 Buffers: shared hit=738658 read=374725 dirtied=1131 written=293 -> Hash (cost=407300.59..407300.59 rows=15149959 width=20) (actual time=15349.141..15349.141 rows=15000000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 761719kB Buffers: shared hit=249246 read=6555 dirtied=1 written=26 -> Seq Scan on orders (cost=0.00..407300.59 rows=15149959 width=20) (actual time=0.020..7786.303 rows=15000000 loops=1) Buffers: shared hit=249246 read=6555 dirtied=1 written=26 Total runtime: 38234.878 ms (19 rows) COMMIT; COMMIT