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-30' and l_shipdate > date '1995-03-30' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2760580.62..2760580.65 rows=10 width=20) (actual time=93932.362..93932.368 rows=10 loops=1) Buffers: shared hit=583188 read=782459 written=23 -> Sort (cost=2760580.62..2768537.39 rows=3182707 width=20) (actual time=93932.357..93932.361 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=583188 read=782459 written=23 -> HashAggregate (cost=2659976.40..2691803.47 rows=3182707 width=20) (actual time=93811.424..93900.666 rows=113537 loops=1) Buffers: shared hit=583182 read=782459 written=23 -> Hash Join (cost=629951.02..2612235.79 rows=3182707 width=20) (actual time=25678.217..93200.042 rows=299783 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=583182 read=782459 written=23 -> Seq Scan on lineitem (cost=0.00..1829724.77 rows=32195449 width=12) (actual time=0.045..40532.003 rows=31989184 loops=1) Filter: (l_shipdate > '1995-03-30'::date) Rows Removed by Filter: 28055480 Buffers: shared hit=292929 read=780989 written=2 -> Hash (cost=611267.28..611267.28 rows=1494699 width=12) (actual time=25675.439..25675.439 rows=1478008 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 63509kB Buffers: shared hit=290253 read=1470 written=21 -> Hash Join (cost=49803.23..611267.28 rows=1494699 width=12) (actual time=628.778..24361.812 rows=1478008 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=290253 read=1470 written=21 -> Seq Scan on orders (cost=0.00..444294.89 rows=7434340 width=16) (actual time=0.019..7039.358 rows=7390475 loops=1) Filter: (o_orderdate < '1995-03-30'::date) Rows Removed by Filter: 7624525 Buffers: shared hit=254976 read=319 written=21 -> Hash (cost=46033.48..46033.48 rows=301580 width=4) (actual time=628.473..628.473 rows=300036 loops=1) Buckets: 32768 Batches: 1 Memory Usage: 10549kB Buffers: shared hit=35277 read=1151 -> Bitmap Heap Scan on customer (cost=6985.73..46033.48 rows=301580 width=4) (actual time=122.797..525.294 rows=300036 loops=1) Recheck Cond: (c_mktsegment = 'AUTOMOBILE'::bpchar) Buffers: shared hit=35277 read=1151 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6910.33 rows=301580 width=0) (actual time=111.136..111.136 rows=300036 loops=1) Index Cond: (c_mktsegment = 'AUTOMOBILE'::bpchar) Buffers: shared hit=2 read=1151 Total runtime: 93976.835 ms (35 rows) COMMIT; COMMIT