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-05' and l_shipdate > date '1995-03-05' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2765486.15..2765486.18 rows=10 width=20) (actual time=113020.175..113020.179 rows=10 loops=1) Buffers: shared hit=1123827 read=244739 written=73 -> Sort (cost=2765486.15..2773446.12 rows=3183989 width=20) (actual time=113020.171..113020.171 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=1123827 read=244739 written=73 -> HashAggregate (cost=2664841.40..2696681.29 rows=3183989 width=20) (actual time=112914.972..112993.989 rows=113242 loops=1) Buffers: shared hit=1123821 read=244739 written=73 -> Hash Join (cost=628272.05..2617081.57 rows=3183989 width=20) (actual time=32743.850..112271.395 rows=299121 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=1123821 read=244739 written=73 -> Seq Scan on lineitem (cost=0.00..1833823.98 rows=32838841 width=12) (actual time=0.039..56714.858 rows=32581445 loops=1) Filter: (l_shipdate > '1995-03-05'::date) Rows Removed by Filter: 27402939 Buffers: shared hit=832744 read=243584 -> Hash (cost=609910.67..609910.67 rows=1468910 width=12) (actual time=32741.838..32741.838 rows=1445001 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 62090kB Buffers: shared hit=291077 read=1155 written=73 -> Hash Join (cost=49840.12..609910.67 rows=1468910 width=12) (actual time=1104.068..31793.072 rows=1445001 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=291077 read=1155 written=73 -> Seq Scan on orders (cost=0.00..445175.49 rows=7287707 width=16) (actual time=0.017..10948.263 rows=7227311 loops=1) Filter: (o_orderdate < '1995-03-05'::date) Rows Removed by Filter: 7772689 Buffers: shared hit=255801 -> Hash (cost=46060.87..46060.87 rows=302340 width=4) (actual time=1103.822..1103.822 rows=300441 loops=1) Buckets: 32768 Batches: 1 Memory Usage: 10563kB Buffers: shared hit=35276 read=1155 written=73 -> Bitmap Heap Scan on customer (cost=7003.62..46060.87 rows=302340 width=4) (actual time=191.420..950.470 rows=300441 loops=1) Recheck Cond: (c_mktsegment = 'MACHINERY'::bpchar) Buffers: shared hit=35276 read=1155 written=73 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6928.03 rows=302340 width=0) (actual time=179.262..179.262 rows=300441 loops=1) Index Cond: (c_mktsegment = 'MACHINERY'::bpchar) Buffers: shared read=1155 written=73 Total runtime: 113055.793 ms (35 rows) COMMIT; COMMIT