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-18' and l_shipdate > date '1995-03-18' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2668250.30..2668250.33 rows=10 width=20) (actual time=27996.367..27996.370 rows=10 loops=1) Buffers: shared hit=803071 read=553359 -> Sort (cost=2668250.30..2676140.00 rows=3155879 width=20) (actual time=27996.363..27996.363 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=803071 read=553359 -> HashAggregate (cost=2568494.10..2600052.89 rows=3155879 width=20) (actual time=27940.637..27977.617 rows=113184 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=803065 read=553359 -> Hash Join (cost=551476.46..2521155.92 rows=3155879 width=20) (actual time=7223.705..27733.190 rows=299040 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=803065 read=553359 -> Seq Scan on lineitem (cost=0.00..1817040.60 rows=32288019 width=12) (actual time=0.029..16003.933 rows=32290776 loops=1) Filter: (l_shipdate > '1995-03-18'::date) Rows Removed by Filter: 27754893 Buffers: shared hit=514268 read=552207 -> Hash (cost=533131.62..533131.62 rows=1467587 width=12) (actual time=7215.952..7215.952 rows=1459400 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 79093kB Buffers: shared hit=288797 read=1152 -> Hash Join (cost=49726.44..533131.62 rows=1467587 width=12) (actual time=459.053..6788.944 rows=1459400 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=288797 read=1152 -> Seq Scan on orders (cost=0.00..441209.30 rows=7338668 width=16) (actual time=0.015..4356.594 rows=7315744 loops=1) Filter: (o_orderdate < '1995-03-18'::date) Rows Removed by Filter: 7699256 Buffers: shared hit=253522 -> Hash (cost=45976.82..45976.82 rows=299970 width=4) (actual time=456.669..456.669 rows=299751 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14635kB Buffers: shared hit=35275 read=1152 -> Bitmap Heap Scan on customer (cost=6949.19..45976.82 rows=299970 width=4) (actual time=67.130..375.074 rows=299751 loops=1) Recheck Cond: (c_mktsegment = 'HOUSEHOLD'::bpchar) Heap Blocks: exact=35275 Buffers: shared hit=35275 read=1152 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6874.20 rows=299970 width=0) (actual time=58.726..58.726 rows=299751 loops=1) Index Cond: (c_mktsegment = 'HOUSEHOLD'::bpchar) Buffers: shared read=1152 Planning time: 5.870 ms Execution time: 28016.513 ms (38 rows) COMMIT; COMMIT