BEGIN; BEGIN EXPLAIN (ANALYZE, BUFFERS) select l_orderkey, sum(l_extendedprice * (1 - l_discount)) as revenue, o_orderdate, o_shippriority from customer, orders, lineitem where c_mktsegment = 'HOUSEHOLD' and c_custkey = o_custkey and l_orderkey = o_orderkey and o_orderdate < date '1995-03-26' and l_shipdate > date '1995-03-26' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2688703.87..2688703.90 rows=10 width=20) (actual time=30055.618..30055.622 rows=10 loops=1) Buffers: shared hit=1011028 read=355929 written=70 -> Sort (cost=2688703.87..2696653.22 rows=3179740 width=20) (actual time=30055.615..30055.618 rows=10 loops=1) Sort Key: (sum((lineitem.l_extendedprice * (1::double precision - lineitem.l_discount)))), orders.o_orderdate Sort Method: top-N heapsort Memory: 25kB Buffers: shared hit=1011028 read=355929 written=70 -> HashAggregate (cost=2588193.43..2619990.83 rows=3179740 width=20) (actual time=29996.915..30036.856 rows=112930 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=1011022 read=355929 written=70 -> Hash Join (cost=555731.00..2540497.33 rows=3179740 width=20) (actual time=8339.819..29772.649 rows=297924 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=1011022 read=355929 written=70 -> Seq Scan on lineitem (cost=0.00..1831531.51 rows=32383311 width=12) (actual time=0.032..16705.032 rows=32056859 loops=1) Filter: (l_shipdate > '1995-03-26'::date) Rows Removed by Filter: 27927063 Buffers: shared hit=864700 read=210276 -> Hash (cost=537154.58..537154.58 rows=1486114 width=12) (actual time=8328.265..8328.265 rows=1467858 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 79457kB Buffers: shared hit=146322 read=145653 written=70 -> Hash Join (cost=49764.48..537154.58 rows=1486114 width=12) (actual time=425.823..7731.922 rows=1467858 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=146322 read=145653 written=70 -> Seq Scan on orders (cost=0.00..444735.19 rows=7411672 width=16) (actual time=0.016..4998.928 rows=7358489 loops=1) Filter: (o_orderdate < '1995-03-26'::date) Rows Removed by Filter: 7641511 Buffers: shared hit=111156 read=144392 written=70 -> Hash (cost=46004.92..46004.92 rows=300765 width=4) (actual time=422.853..422.853 rows=299751 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14635kB Buffers: shared hit=35166 read=1261 -> Bitmap Heap Scan on customer (cost=6967.36..46004.92 rows=300765 width=4) (actual time=64.987..346.269 rows=299751 loops=1) Recheck Cond: (c_mktsegment = 'HOUSEHOLD'::bpchar) Heap Blocks: exact=35275 Buffers: shared hit=35166 read=1261 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6892.16 rows=300765 width=0) (actual time=56.911..56.911 rows=299751 loops=1) Index Cond: (c_mktsegment = 'HOUSEHOLD'::bpchar) Buffers: shared read=1152 Planning time: 3.473 ms Execution time: 30083.187 ms (38 rows) COMMIT; COMMIT