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', 'FOB') and l_commitdate < l_receiptdate and l_shipdate < l_commitdate and l_receiptdate >= date '1993-01-01' and l_receiptdate < date '1993-01-01' + interval '1 year' group by l_shipmode order by l_shipmode; QUERY PLAN --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Sort (cost=982242.43..982242.44 rows=1 width=27) (actual time=53075.460..53075.460 rows=2 loops=1) Sort Key: lineitem.l_shipmode Sort Method: quicksort Memory: 25kB Buffers: shared hit=891527 read=474890 dirtied=1085 written=2234 -> HashAggregate (cost=982242.41..982242.42 rows=1 width=27) (actual time=53075.348..53075.349 rows=2 loops=1) Buffers: shared hit=891522 read=474890 dirtied=1085 written=2234 -> Hash Join (cost=592539.42..977152.73 rows=290839 width=27) (actual time=18718.402..52358.045 rows=312353 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=891522 read=474890 dirtied=1085 written=2234 -> Index Scan using lineitem_l_orderkey_idx_part2 on lineitem (cost=0.00..375524.59 rows=290839 width=15) (actual time=0.281..31863.235 rows=312353 loops=1) Filter: ((l_shipmode = ANY ('{"REG AIR",FOB}'::bpchar[])) AND (l_receiptdate >= '1993-01-01'::date) AND (l_receiptdate < '1994-01-01 00:00:00'::timestamp without time zone)) Rows Removed by Filter: 6877709 Buffers: shared hit=639082 read=473299 dirtied=1082 written=2158 -> Hash (cost=404477.52..404477.52 rows=15044952 width=20) (actual time=18703.706..18703.706 rows=15000000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 761719kB Buffers: shared hit=252437 read=1591 dirtied=3 written=76 -> Seq Scan on orders (cost=0.00..404477.52 rows=15044952 width=20) (actual time=0.030..9251.518 rows=15000000 loops=1) Buffers: shared hit=252437 read=1591 dirtied=3 written=76 Total runtime: 53272.933 ms (19 rows) COMMIT; COMMIT