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 = 'BUILDING' and c_custkey = o_custkey and l_orderkey = o_orderkey and o_orderdate < date '1995-03-14' and l_shipdate > date '1995-03-14' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2698465.05..2698465.07 rows=10 width=20) (actual time=34553.220..34553.224 rows=10 loops=1) Buffers: shared hit=825663 read=546596 dirtied=45 written=4176 -> Sort (cost=2698465.05..2706403.22 rows=3175268 width=20) (actual time=34553.217..34553.219 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=825663 read=546596 dirtied=45 written=4176 -> HashAggregate (cost=2598095.97..2629848.65 rows=3175268 width=20) (actual time=34474.445..34532.844 rows=114177 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=825657 read=546596 dirtied=45 written=4176 -> Hash Join (cost=557029.81..2550466.95 rows=3175268 width=20) (actual time=9394.805..34216.149 rows=302557 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=825657 read=546596 dirtied=45 written=4176 -> Seq Scan on lineitem (cost=0.00..1838834.20 rows=32760070 width=12) (actual time=0.051..18112.120 rows=32390055 loops=1) Filter: (l_shipdate > '1995-03-14'::date) Rows Removed by Filter: 27655242 Buffers: shared hit=598847 read=480415 -> Hash (cost=538620.23..538620.23 rows=1472766 width=12) (actual time=9376.562..9376.562 rows=1462004 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 79205kB Buffers: shared hit=226810 read=66181 dirtied=45 written=4176 -> Hash Join (cost=49672.78..538620.23 rows=1472766 width=12) (actual time=857.609..8727.969 rows=1462004 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=226810 read=66181 dirtied=45 written=4176 -> Seq Scan on orders (cost=0.00..446496.39 rows=7392907 width=16) (actual time=0.026..4889.366 rows=7290782 loops=1) Filter: (o_orderdate < '1995-03-14'::date) Rows Removed by Filter: 7724218 Buffers: shared hit=226808 read=29752 dirtied=45 written=243 -> Hash (cost=45937.53..45937.53 rows=298820 width=4) (actual time=853.322..853.322 rows=300276 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14653kB Buffers: shared hit=2 read=36429 written=3933 -> Bitmap Heap Scan on customer (cost=6924.28..45937.53 rows=298820 width=4) (actual time=76.724..742.617 rows=300276 loops=1) Recheck Cond: (c_mktsegment = 'BUILDING'::bpchar) Heap Blocks: exact=35277 Buffers: shared hit=2 read=36429 written=3933 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6849.58 rows=298820 width=0) (actual time=67.996..67.996 rows=300276 loops=1) Index Cond: (c_mktsegment = 'BUILDING'::bpchar) Buffers: shared read=1154 written=144 Planning time: 4.047 ms Execution time: 34578.969 ms (38 rows) COMMIT; COMMIT