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=2747406.64..2747406.67 rows=10 width=20) (actual time=74030.350..74030.355 rows=10 loops=1) Buffers: shared hit=1108873 read=250197 written=3 -> Sort (cost=2747406.64..2755321.36 rows=3165887 width=20) (actual time=74030.345..74030.346 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=1108873 read=250197 written=3 -> HashAggregate (cost=2647334.09..2678992.96 rows=3165887 width=20) (actual time=73887.622..73996.603 rows=113189 loops=1) Buffers: shared hit=1108867 read=250197 written=3 -> Hash Join (cost=626017.52..2599845.79 rows=3165887 width=20) (actual time=28545.320..73495.004 rows=299045 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=1108867 read=250197 written=3 -> Seq Scan on lineitem (cost=0.00..1820673.96 rows=32398783 width=12) (actual time=0.056..23324.999 rows=32290128 loops=1) Filter: (l_shipdate > '1995-03-18'::date) Rows Removed by Filter: 27755251 Buffers: shared hit=830933 read=237675 -> Hash (cost=607640.82..607640.82 rows=1470136 width=12) (actual time=28540.764..28540.764 rows=1459412 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 62710kB Buffers: shared hit=277934 read=12522 written=3 -> Hash Join (cost=49722.08..607640.82 rows=1470136 width=12) (actual time=1120.420..24813.468 rows=1459412 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=277934 read=12522 written=3 -> Seq Scan on orders (cost=0.00..442089.90 rows=7354726 width=16) (actual time=0.019..6084.159 rows=7315809 loops=1) Filter: (o_orderdate < '1995-03-18'::date) Rows Removed by Filter: 7699191 Buffers: shared hit=242842 read=11186 written=3 -> Hash (cost=45974.14..45974.14 rows=299835 width=4) (actual time=1120.121..1120.121 rows=299751 loops=1) Buckets: 32768 Batches: 1 Memory Usage: 10539kB Buffers: shared hit=35092 read=1336 -> Bitmap Heap Scan on customer (cost=6948.20..45974.14 rows=299835 width=4) (actual time=531.817..983.401 rows=299751 loops=1) Recheck Cond: (c_mktsegment = 'HOUSEHOLD'::bpchar) Buffers: shared hit=35092 read=1336 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6873.24 rows=299835 width=0) (actual time=517.286..517.286 rows=299751 loops=1) Index Cond: (c_mktsegment = 'HOUSEHOLD'::bpchar) Buffers: shared read=1153 Total runtime: 74080.930 ms (35 rows) COMMIT; COMMIT