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-07' and l_shipdate > date '1995-03-07' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2738413.48..2738413.51 rows=10 width=20) (actual time=112764.930..112764.934 rows=10 loops=1) Buffers: shared hit=1018691 read=337740 dirtied=254 written=596 -> Sort (cost=2738413.48..2746216.17 rows=3121074 width=20) (actual time=112764.927..112764.928 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=1018691 read=337740 dirtied=254 written=596 -> HashAggregate (cost=2639757.45..2670968.19 rows=3121074 width=20) (actual time=112680.416..112746.688 rows=113038 loops=1) Buffers: shared hit=1018685 read=337740 dirtied=254 written=596 -> Hash Join (cost=622858.86..2592941.34 rows=3121074 width=20) (actual time=32501.411..112062.218 rows=298612 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=1018685 read=337740 dirtied=254 written=596 -> Seq Scan on lineitem (cost=0.00..1817036.65 rows=32489358 width=12) (actual time=0.065..56779.292 rows=32533369 loops=1) Filter: (l_shipdate > '1995-03-07'::date) Rows Removed by Filter: 27451960 Buffers: shared hit=756247 read=310228 written=5 -> Hash (cost=604828.77..604828.77 rows=1442407 width=12) (actual time=32498.810..32498.810 rows=1444110 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 62052kB Buffers: shared hit=262438 read=27512 dirtied=254 written=591 -> Hash Join (cost=49676.60..604828.77 rows=1442407 width=12) (actual time=1951.178..31572.733 rows=1444110 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=262438 read=27512 dirtied=254 written=591 -> Seq Scan on orders (cost=0.00..441209.30 rows=7237731 width=16) (actual time=0.019..11842.771 rows=7239643 loops=1) Filter: (o_orderdate < '1995-03-07'::date) Rows Removed by Filter: 7760357 Buffers: shared hit=231561 read=21961 dirtied=254 written=591 -> Hash (cost=45939.91..45939.91 rows=298935 width=4) (actual time=1950.925..1950.925 rows=299751 loops=1) Buckets: 32768 Batches: 1 Memory Usage: 10539kB Buffers: shared hit=30877 read=5551 -> Bitmap Heap Scan on customer (cost=6925.23..45939.91 rows=298935 width=4) (actual time=281.351..1780.714 rows=299751 loops=1) Recheck Cond: (c_mktsegment = 'HOUSEHOLD'::bpchar) Buffers: shared hit=30877 read=5551 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6850.49 rows=298935 width=0) (actual time=266.353..266.353 rows=299751 loops=1) Index Cond: (c_mktsegment = 'HOUSEHOLD'::bpchar) Buffers: shared read=1153 Total runtime: 112796.656 ms (35 rows) COMMIT; COMMIT