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 = 'HOUSEHOLD' and c_custkey = o_custkey and l_orderkey = o_orderkey and o_orderdate < date '1995-03-25' and l_shipdate > date '1995-03-25' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2688859.31..2688859.33 rows=10 width=20) (actual time=42677.980..42677.986 rows=10 loops=1) Buffers: shared hit=830897 read=537383 written=176 -> Sort (cost=2688859.31..2696728.51 rows=3147683 width=20) (actual time=42677.976..42677.978 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=830897 read=537383 written=176 -> HashAggregate (cost=2589362.18..2620839.01 rows=3147683 width=20) (actual time=42603.691..42655.854 rows=113116 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=830891 read=537383 written=176 -> Hash Join (cost=555591.86..2542146.93 rows=3147683 width=20) (actual time=14103.795..42289.893 rows=298389 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=830891 read=537383 written=176 -> Seq Scan on lineitem (cost=0.00..1833350.52 rows=32460724 width=12) (actual time=0.019..20269.719 rows=32113916 loops=1) Filter: (l_shipdate > '1995-03-25'::date) Rows Removed by Filter: 27930260 Buffers: shared hit=623027 read=453019 written=4 -> Hash (cost=537228.41..537228.41 rows=1469076 width=12) (actual time=14093.843..14093.843 rows=1468073 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 79466kB Buffers: shared hit=207864 read=84364 written=172 -> Hash Join (cost=49634.91..537228.41 rows=1469076 width=12) (actual time=522.786..13209.056 rows=1468073 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=207864 read=84364 written=172 -> Seq Scan on orders (cost=0.00..445175.49 rows=7393935 width=16) (actual time=0.029..7104.385 rows=7359642 loops=1) Filter: (o_orderdate < '1995-03-25'::date) Rows Removed by Filter: 7655358 Buffers: shared hit=172589 read=83212 written=171 -> Hash (cost=45909.54..45909.54 rows=298030 width=4) (actual time=520.295..520.295 rows=299751 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14635kB Buffers: shared hit=35275 read=1152 written=1 -> Bitmap Heap Scan on customer (cost=6906.16..45909.54 rows=298030 width=4) (actual time=76.371..434.054 rows=299751 loops=1) Recheck Cond: (c_mktsegment = 'HOUSEHOLD'::bpchar) Heap Blocks: exact=35275 Buffers: shared hit=35275 read=1152 written=1 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6831.65 rows=298030 width=0) (actual time=66.986..66.986 rows=299751 loops=1) Index Cond: (c_mktsegment = 'HOUSEHOLD'::bpchar) Buffers: shared read=1152 written=1 Planning time: 3.952 ms Execution time: 42701.215 ms (38 rows) COMMIT; COMMIT