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-18' and l_shipdate > date '1995-03-18' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2670577.55..2670577.57 rows=10 width=20) (actual time=32398.070..32398.075 rows=10 loops=1) Buffers: shared hit=846069 read=511685 written=7 -> Sort (cost=2670577.55..2678465.74 rows=3155276 width=20) (actual time=32398.066..32398.068 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=846069 read=511685 written=7 -> HashAggregate (cost=2570840.41..2602393.17 rows=3155276 width=20) (actual time=32322.418..32377.305 rows=113934 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=846063 read=511685 written=7 -> Hash Join (cost=551935.98..2523511.27 rows=3155276 width=20) (actual time=8469.789..32057.700 rows=300571 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=846063 read=511685 written=7 -> Seq Scan on lineitem (cost=0.00..1818872.61 rows=32306644 width=12) (actual time=0.048..17788.336 rows=32290378 loops=1) Filter: (l_shipdate > '1995-03-18'::date) Rows Removed by Filter: 27755225 Buffers: shared hit=619580 read=447966 written=7 -> Hash (cost=533586.93..533586.93 rows=1467924 width=12) (actual time=8449.227..8449.227 rows=1463039 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 79249kB Buffers: shared hit=226483 read=63719 -> Hash Join (cost=49723.50..533586.93 rows=1467924 width=12) (actual time=766.355..7915.031 rows=1463039 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=226483 read=63719 -> Seq Scan on orders (cost=0.00..441649.60 rows=7342558 width=16) (actual time=0.027..4594.207 rows=7315843 loops=1) Filter: (o_orderdate < '1995-03-18'::date) Rows Removed by Filter: 7699157 Buffers: shared hit=226481 read=27294 -> Hash (cost=45975.00..45975.00 rows=299880 width=4) (actual time=763.108..763.108 rows=300036 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14645kB Buffers: shared hit=2 read=36425 -> Bitmap Heap Scan on customer (cost=6948.50..45975.00 rows=299880 width=4) (actual time=72.365..659.321 rows=300036 loops=1) Recheck Cond: (c_mktsegment = 'AUTOMOBILE'::bpchar) Heap Blocks: exact=35275 Buffers: shared hit=2 read=36425 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6873.53 rows=299880 width=0) (actual time=63.107..63.107 rows=300036 loops=1) Index Cond: (c_mktsegment = 'AUTOMOBILE'::bpchar) Buffers: shared read=1152 Planning time: 3.942 ms Execution time: 32475.793 ms (38 rows) COMMIT; COMMIT