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-12' and l_shipdate > date '1995-03-12' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2745467.24..2745467.27 rows=10 width=20) (actual time=109885.814..109885.817 rows=10 loops=1) Buffers: shared hit=990959 read=368111 written=538 -> Sort (cost=2745467.24..2753326.66 rows=3143767 width=20) (actual time=109885.811..109885.812 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=990959 read=368111 written=538 -> HashAggregate (cost=2646093.90..2677531.57 rows=3143767 width=20) (actual time=109808.357..109866.056 rows=113871 loops=1) Buffers: shared hit=990953 read=368111 written=538 -> Hash Join (cost=624680.75..2598937.39 rows=3143767 width=20) (actual time=36420.575..109153.686 rows=300620 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=990953 read=368111 written=538 -> Seq Scan on lineitem (cost=0.00..1820676.68 rows=32571279 width=12) (actual time=0.049..46996.804 rows=32440661 loops=1) Filter: (l_shipdate > '1995-03-12'::date) Rows Removed by Filter: 27604718 Buffers: shared hit=738157 read=330451 written=538 -> Hash (cost=606529.09..606529.09 rows=1452133 width=12) (actual time=36418.446..36418.446 rows=1455429 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 62538kB Buffers: shared hit=252796 read=37660 -> Hash Join (cost=49671.03..606529.09 rows=1452133 width=12) (actual time=2119.137..35099.837 rows=1455429 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=252796 read=37660 -> Seq Scan on orders (cost=0.00..442089.90 rows=7290678 width=16) (actual time=0.015..10725.722 rows=7278083 loops=1) Filter: (o_orderdate < '1995-03-12'::date) Rows Removed by Filter: 7736917 Buffers: shared hit=252793 read=1235 -> Hash (cost=45936.47..45936.47 rows=298765 width=4) (actual time=2118.461..2118.461 rows=300036 loops=1) Buckets: 32768 Batches: 1 Memory Usage: 10549kB Buffers: shared hit=3 read=36425 -> Bitmap Heap Scan on customer (cost=6923.91..45936.47 rows=298765 width=4) (actual time=81.700..1588.409 rows=300036 loops=1) Recheck Cond: (c_mktsegment = 'AUTOMOBILE'::bpchar) Buffers: shared hit=3 read=36425 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6849.22 rows=298765 width=0) (actual time=73.030..73.030 rows=300036 loops=1) Index Cond: (c_mktsegment = 'AUTOMOBILE'::bpchar) Buffers: shared read=1153 Total runtime: 110461.953 ms (35 rows) COMMIT; COMMIT