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=990791.58..990791.58 rows=1 width=27) (actual time=26089.592..26089.593 rows=2 loops=1) Sort Key: lineitem.l_shipmode Sort Method: quicksort Memory: 25kB Buffers: shared hit=936480 read=437110 dirtied=998 written=5456 -> HashAggregate (cost=990791.56..990791.57 rows=1 width=27) (actual time=26089.524..26089.525 rows=2 loops=1) Group Key: lineitem.l_shipmode Buffers: shared hit=936475 read=437110 dirtied=998 written=5456 -> Hash Join (cost=597855.79..985647.69 rows=293935 width=27) (actual time=12444.338..25763.052 rows=312210 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=936475 read=437110 dirtied=998 written=5456 -> Index Scan using lineitem_l_orderkey_idx_part2 on lineitem (cost=0.43..378606.87 rows=293935 width=15) (actual time=0.098..12812.804 rows=312210 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: 6877186 Buffers: shared hit=834553 read=282722 dirtied=813 written=288 -> Hash (cost=408106.27..408106.27 rows=15179927 width=20) (actual time=12344.060..12344.060 rows=15000000 loops=1) Buckets: 16777216 Batches: 1 Memory Usage: 892791kB Buffers: shared hit=101919 read=154388 dirtied=185 written=5168 -> Seq Scan on orders (cost=0.00..408106.27 rows=15179927 width=20) (actual time=0.020..5759.955 rows=15000000 loops=1) Buffers: shared hit=101919 read=154388 dirtied=185 written=5168 Planning time: 2.821 ms Execution time: 26121.021 ms (21 rows) COMMIT; COMMIT