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-02' and l_shipdate > date '1995-03-02' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2668768.65..2668768.67 rows=10 width=20) (actual time=28383.959..28383.963 rows=10 loops=1) Buffers: shared hit=802568 read=553862 -> Sort (cost=2668768.65..2676652.35 rows=3153479 width=20) (actual time=28383.953..28383.956 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=802568 read=553862 -> HashAggregate (cost=2569088.31..2600623.10 rows=3153479 width=20) (actual time=28328.421..28364.911 rows=113125 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=802562 read=553862 -> Hash Join (cost=550709.61..2521786.13 rows=3153479 width=20) (actual time=7096.419..28118.446 rows=298408 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=802562 read=553862 -> Seq Scan on lineitem (cost=0.00..1817047.86 rows=32665031 width=12) (actual time=0.028..16491.228 rows=32691598 loops=1) Filter: (l_shipdate > '1995-03-02'::date) Rows Removed by Filter: 27354071 Buffers: shared hit=513765 read=552710 -> Hash (cost=532590.30..532590.30 rows=1449545 width=12) (actual time=7088.558..7088.558 rows=1439365 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 78232kB Buffers: shared hit=288797 read=1152 -> Hash Join (cost=49751.80..532590.30 rows=1449545 width=12) (actual time=438.536..6677.148 rows=1439365 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=288797 read=1152 -> Seq Scan on orders (cost=0.00..441209.30 rows=7235665 width=16) (actual time=0.016..4310.719 rows=7215287 loops=1) Filter: (o_orderdate < '1995-03-02'::date) Rows Removed by Filter: 7799713 Buffers: shared hit=253522 -> Hash (cost=45995.55..45995.55 rows=300500 width=4) (actual time=436.046..436.046 rows=299751 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14635kB Buffers: shared hit=35275 read=1152 -> Bitmap Heap Scan on customer (cost=6961.30..45995.55 rows=300500 width=4) (actual time=66.951..362.513 rows=299751 loops=1) Recheck Cond: (c_mktsegment = 'HOUSEHOLD'::bpchar) Heap Blocks: exact=35275 Buffers: shared hit=35275 read=1152 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6886.18 rows=300500 width=0) (actual time=58.565..58.565 rows=299751 loops=1) Index Cond: (c_mktsegment = 'HOUSEHOLD'::bpchar) Buffers: shared read=1152 Planning time: 5.514 ms Execution time: 28401.821 ms (38 rows) COMMIT; COMMIT