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 = 'AUTOMOBILE' and c_custkey = o_custkey and l_orderkey = o_orderkey and o_orderdate < date '1995-03-26' and l_shipdate > date '1995-03-26' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2745978.79..2745978.82 rows=10 width=20) (actual time=97281.960..97281.965 rows=10 loops=1) Buffers: shared hit=819841 read=538733 dirtied=752 written=713 -> Sort (cost=2745978.79..2753892.13 rows=3165336 width=20) (actual time=97281.956..97281.958 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=819841 read=538733 dirtied=752 written=713 -> HashAggregate (cost=2645923.66..2677577.02 rows=3165336 width=20) (actual time=97197.684..97262.105 rows=113541 loops=1) Buffers: shared hit=819835 read=538733 dirtied=752 written=713 -> Hash Join (cost=626087.30..2598443.62 rows=3165336 width=20) (actual time=34835.960..96581.963 rows=299868 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=819835 read=538733 dirtied=752 written=713 -> Seq Scan on lineitem (cost=0.00..1820263.66 rows=32117146 width=12) (actual time=0.082..35678.007 rows=32059021 loops=1) Filter: (l_shipdate > '1995-03-26'::date) Rows Removed by Filter: 27926531 Buffers: shared hit=564939 read=503426 dirtied=749 written=192 -> Hash (cost=607571.14..607571.14 rows=1481293 width=12) (actual time=34833.430..34833.430 rows=1471457 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 63227kB Buffers: shared hit=254896 read=35307 dirtied=3 written=521 -> Hash Join (cost=49803.23..607571.14 rows=1481293 width=12) (actual time=1237.381..30175.369 rows=1471457 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=254896 read=35307 dirtied=3 written=521 -> Seq Scan on orders (cost=0.00..441649.60 rows=7367664 width=16) (actual time=0.016..8247.481 rows=7358162 loops=1) Filter: (o_orderdate < '1995-03-26'::date) Rows Removed by Filter: 7641838 Buffers: shared hit=219621 read=34154 dirtied=3 written=521 -> Hash (cost=46033.48..46033.48 rows=301580 width=4) (actual time=1237.141..1237.141 rows=300036 loops=1) Buckets: 32768 Batches: 1 Memory Usage: 10549kB Buffers: shared hit=35275 read=1153 -> Bitmap Heap Scan on customer (cost=6985.73..46033.48 rows=301580 width=4) (actual time=80.725..518.014 rows=300036 loops=1) Recheck Cond: (c_mktsegment = 'AUTOMOBILE'::bpchar) Buffers: shared hit=35275 read=1153 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6910.33 rows=301580 width=0) (actual time=70.894..70.894 rows=300036 loops=1) Index Cond: (c_mktsegment = 'AUTOMOBILE'::bpchar) Buffers: shared read=1153 Total runtime: 98256.178 ms (35 rows) COMMIT; COMMIT