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 = 'MACHINERY' and c_custkey = o_custkey and l_orderkey = o_orderkey and o_orderdate < date '1995-03-03' and l_shipdate > date '1995-03-03' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2748645.04..2748645.06 rows=10 width=20) (actual time=146831.250..146831.256 rows=10 loops=1) Buffers: shared hit=652334 read=708050 written=3 -> Sort (cost=2748645.04..2756551.59 rows=3162619 width=20) (actual time=146831.246..146831.248 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=652334 read=708050 written=3 -> HashAggregate (cost=2648675.79..2680301.98 rows=3162619 width=20) (actual time=146732.281..146809.523 rows=113456 loops=1) Buffers: shared hit=652328 read=708050 written=3 -> Hash Join (cost=624606.44..2601236.50 rows=3162619 width=20) (actual time=45954.996..146011.026 rows=299754 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=652328 read=708050 written=3 -> Seq Scan on lineitem (cost=0.00..1822473.40 rows=32674793 width=12) (actual time=0.029..72370.370 rows=32666038 loops=1) Filter: (l_shipdate > '1995-03-03'::date) Rows Removed by Filter: 27379265 Buffers: shared hit=438380 read=631286 written=3 -> Hash (cost=606385.65..606385.65 rows=1457663 width=12) (actual time=45951.166..45951.166 rows=1443941 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 62045kB Buffers: shared hit=213948 read=76764 -> Hash Join (cost=49840.12..606385.65 rows=1457663 width=12) (actual time=4207.211..43662.063 rows=1443941 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=213948 read=76764 -> Seq Scan on orders (cost=0.00..442530.20 rows=7231906 width=16) (actual time=0.019..17086.531 rows=7221755 loops=1) Filter: (o_orderdate < '1995-03-03'::date) Rows Removed by Filter: 7793245 Buffers: shared hit=213945 read=40336 -> Hash (cost=46060.87..46060.87 rows=302340 width=4) (actual time=4206.906..4206.906 rows=300441 loops=1) Buckets: 32768 Batches: 1 Memory Usage: 10563kB Buffers: shared hit=3 read=36428 -> Bitmap Heap Scan on customer (cost=7003.62..46060.87 rows=302340 width=4) (actual time=210.256..4008.254 rows=300441 loops=1) Recheck Cond: (c_mktsegment = 'MACHINERY'::bpchar) Buffers: shared hit=3 read=36428 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6928.03 rows=302340 width=0) (actual time=194.126..194.126 rows=300441 loops=1) Index Cond: (c_mktsegment = 'MACHINERY'::bpchar) Buffers: shared read=1155 Total runtime: 146885.703 ms (35 rows) COMMIT; COMMIT