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-22' and l_shipdate > date '1995-03-22' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2678891.09..2678891.12 rows=10 width=20) (actual time=31068.109..31068.112 rows=10 loops=1) Buffers: shared hit=332023 read=1029684 -> Sort (cost=2678891.09..2686823.46 rows=3172947 width=20) (actual time=31068.105..31068.106 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=332023 read=1029684 -> HashAggregate (cost=2578595.38..2610324.85 rows=3172947 width=20) (actual time=30999.721..31049.136 rows=113007 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=332017 read=1029684 -> Hash Join (cost=553730.46..2531001.18 rows=3172947 width=20) (actual time=7619.745..30772.936 rows=298305 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=332017 read=1029684 -> Seq Scan on lineitem (cost=0.00..1824307.23 rows=32329071 width=12) (actual time=0.083..15872.711 rows=32158407 loops=1) Filter: (l_shipdate > '1995-03-22'::date) Rows Removed by Filter: 27827901 Buffers: shared hit=42207 read=1028533 -> Hash (cost=535236.30..535236.30 rows=1479533 width=12) (actual time=7608.108..7608.108 rows=1462907 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 79244kB Buffers: shared hit=289810 read=1151 -> Hash Join (cost=49726.44..535236.30 rows=1479533 width=12) (actual time=378.997..7044.177 rows=1462907 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=289810 read=1151 -> Seq Scan on orders (cost=0.00..442970.50 rows=7398407 width=16) (actual time=0.012..3923.295 rows=7333519 loops=1) Filter: (o_orderdate < '1995-03-22'::date) Rows Removed by Filter: 7666481 Buffers: shared hit=254534 -> Hash (cost=45976.82..45976.82 rows=299970 width=4) (actual time=376.227..376.227 rows=299751 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14635kB Buffers: shared hit=35276 read=1151 -> Bitmap Heap Scan on customer (cost=6949.19..45976.82 rows=299970 width=4) (actual time=59.261..293.851 rows=299751 loops=1) Recheck Cond: (c_mktsegment = 'HOUSEHOLD'::bpchar) Heap Blocks: exact=35275 Buffers: shared hit=35276 read=1151 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6874.20 rows=299970 width=0) (actual time=51.792..51.792 rows=299751 loops=1) Index Cond: (c_mktsegment = 'HOUSEHOLD'::bpchar) Buffers: shared hit=1 read=1151 Planning time: 2.987 ms Execution time: 31086.968 ms (38 rows) COMMIT; COMMIT