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-01' and l_shipdate > date '1995-03-01' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2760832.01..2760832.04 rows=10 width=20) (actual time=62265.883..62265.889 rows=10 loops=1) Buffers: shared hit=697346 read=669616 written=4 -> Sort (cost=2760832.01..2768727.12 rows=3158044 width=20) (actual time=62265.879..62265.881 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=697346 read=669616 written=4 -> HashAggregate (cost=2661007.37..2692587.81 rows=3158044 width=20) (actual time=62163.777..62244.800 rows=113994 loops=1) Buffers: shared hit=697340 read=669616 written=4 -> Hash Join (cost=626823.78..2613636.71 rows=3158044 width=20) (actual time=23250.693..61704.048 rows=301823 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=697340 read=669616 written=4 -> Seq Scan on lineitem (cost=0.00..1831532.52 rows=32986659 width=12) (actual time=0.047..19885.837 rows=32714262 loops=1) Filter: (l_shipdate > '1995-03-01'::date) Rows Removed by Filter: 27329820 Buffers: shared hit=443671 read=631305 written=4 -> Hash (cost=608711.57..608711.57 rows=1448977 width=12) (actual time=23248.452..23248.452 rows=1445673 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 62119kB Buffers: shared hit=253669 read=38311 -> Hash Join (cost=49703.11..608711.57 rows=1448977 width=12) (actual time=1025.337..22454.179 rows=1445673 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=253669 read=38311 -> Seq Scan on orders (cost=0.00..444735.19 rows=7256982 width=16) (actual time=0.016..5308.513 rows=7209350 loops=1) Filter: (o_orderdate < '1995-03-01'::date) Rows Removed by Filter: 7805650 Buffers: shared hit=253667 read=1881 -> Hash (cost=45959.36..45959.36 rows=299500 width=4) (actual time=1025.034..1025.034 rows=300276 loops=1) Buckets: 32768 Batches: 1 Memory Usage: 10557kB Buffers: shared hit=2 read=36430 -> Bitmap Heap Scan on customer (cost=6937.61..45959.36 rows=299500 width=4) (actual time=77.699..881.874 rows=300276 loops=1) Recheck Cond: (c_mktsegment = 'BUILDING'::bpchar) Buffers: shared hit=2 read=36430 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6862.73 rows=299500 width=0) (actual time=68.205..68.205 rows=300276 loops=1) Index Cond: (c_mktsegment = 'BUILDING'::bpchar) Buffers: shared read=1155 Total runtime: 62312.240 ms (35 rows) COMMIT; COMMIT