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-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=2758912.01..2758912.04 rows=10 width=20) (actual time=87112.478..87112.484 rows=10 loops=1) Buffers: shared hit=1128690 read=236957 written=7 -> Sort (cost=2758912.01..2766824.89 rows=3165152 width=20) (actual time=87112.475..87112.478 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=1128690 read=236957 written=7 -> HashAggregate (cost=2658862.70..2690514.22 rows=3165152 width=20) (actual time=87009.327..87090.198 rows=113061 loops=1) Buffers: shared hit=1128684 read=236957 written=7 -> Hash Join (cost=626945.54..2611385.42 rows=3165152 width=20) (actual time=27866.855..86496.178 rows=298601 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=1128684 read=236957 written=7 -> Seq Scan on lineitem (cost=0.00..1829724.77 rows=32816956 width=12) (actual time=0.066..34527.903 rows=32614421 loops=1) Filter: (l_shipdate > '1995-03-05'::date) Rows Removed by Filter: 27430243 Buffers: shared hit=862236 read=211682 written=7 -> Hash (cost=608716.75..608716.75 rows=1458303 width=12) (actual time=27864.426..27864.426 rows=1443190 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 62013kB Buffers: shared hit=266448 read=25275 -> Hash Join (cost=49752.35..608716.75 rows=1458303 width=12) (actual time=1155.812..26331.955 rows=1443190 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=266448 read=25275 -> Seq Scan on orders (cost=0.00..444294.89 rows=7279017 width=16) (actual time=0.037..7344.356 rows=7234529 loops=1) Filter: (o_orderdate < '1995-03-05'::date) Rows Removed by Filter: 7780471 Buffers: shared hit=255245 read=50 -> Hash (cost=45995.91..45995.91 rows=300515 width=4) (actual time=1155.520..1155.520 rows=299751 loops=1) Buckets: 32768 Batches: 1 Memory Usage: 10539kB Buffers: shared hit=11203 read=25225 -> Bitmap Heap Scan on customer (cost=6961.47..45995.91 rows=300515 width=4) (actual time=135.572..1003.509 rows=299751 loops=1) Recheck Cond: (c_mktsegment = 'HOUSEHOLD'::bpchar) Buffers: shared hit=11203 read=25225 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6886.34 rows=300515 width=0) (actual time=123.155..123.155 rows=299751 loops=1) Index Cond: (c_mktsegment = 'HOUSEHOLD'::bpchar) Buffers: shared read=1153 Total runtime: 87153.896 ms (35 rows) COMMIT; COMMIT