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-27' and l_shipdate > date '1995-03-27' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2764629.81..2764629.84 rows=10 width=20) (actual time=86154.601..86154.604 rows=10 loops=1) Buffers: shared hit=1003035 read=363923 dirtied=27 written=1 -> Sort (cost=2764629.81..2772633.34 rows=3201410 width=20) (actual time=86154.596..86154.598 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=1003035 read=363923 dirtied=27 written=1 -> HashAggregate (cost=2663434.39..2695448.49 rows=3201410 width=20) (actual time=86065.007..86135.603 rows=113040 loops=1) Buffers: shared hit=1003029 read=363923 dirtied=27 written=1 -> Hash Join (cost=630408.93..2615413.24 rows=3201410 width=20) (actual time=30260.384..85548.571 rows=298085 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=1003029 read=363923 dirtied=27 written=1 -> Seq Scan on lineitem (cost=0.00..1831526.36 rows=32390359 width=12) (actual time=0.056..34630.994 rows=32031708 loops=1) Filter: (l_shipdate > '1995-03-27'::date) Rows Removed by Filter: 27952214 Buffers: shared hit=749047 read=325929 -> Hash (cost=611709.98..611709.98 rows=1495916 width=12) (actual time=30257.815..30257.815 rows=1469132 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 63127kB Buffers: shared hit=253982 read=37994 dirtied=27 written=1 -> Hash Join (cost=49822.03..611709.98 rows=1495916 width=12) (actual time=1254.670..29369.132 rows=1469132 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=253982 read=37994 dirtied=27 written=1 -> Seq Scan on orders (cost=0.00..444735.19 rows=7432262 width=16) (actual time=0.020..9349.563 rows=7364711 loops=1) Filter: (o_orderdate < '1995-03-27'::date) Rows Removed by Filter: 7635289 Buffers: shared hit=253979 read=1569 dirtied=27 written=1 -> Hash (cost=46048.16..46048.16 rows=301910 width=4) (actual time=1254.176..1254.176 rows=299751 loops=1) Buckets: 32768 Batches: 1 Memory Usage: 10539kB Buffers: shared hit=3 read=36425 -> Bitmap Heap Scan on customer (cost=6996.28..46048.16 rows=301910 width=4) (actual time=111.732..1085.414 rows=299751 loops=1) Recheck Cond: (c_mktsegment = 'HOUSEHOLD'::bpchar) Buffers: shared hit=3 read=36425 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6920.81 rows=301910 width=0) (actual time=99.390..99.390 rows=299751 loops=1) Index Cond: (c_mktsegment = 'HOUSEHOLD'::bpchar) Buffers: shared read=1153 Total runtime: 86192.982 ms (35 rows) COMMIT; COMMIT