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 = 'FURNITURE' and c_custkey = o_custkey and l_orderkey = o_orderkey and o_orderdate < date '1995-03-15' and l_shipdate > date '1995-03-15' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2770510.03..2770510.06 rows=10 width=20) (actual time=153425.209..153425.214 rows=10 loops=1) Buffers: shared hit=720929 read=651325 dirtied=252 written=17 -> Sort (cost=2770510.03..2778399.45 rows=3155766 width=20) (actual time=153425.205..153425.207 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=720929 read=651325 dirtied=252 written=17 -> HashAggregate (cost=2670757.40..2702315.06 rows=3155766 width=20) (actual time=153324.863..153402.039 rows=113413 loops=1) Buffers: shared hit=720923 read=651325 dirtied=252 written=17 -> Hash Join (cost=630567.69..2623420.91 rows=3155766 width=20) (actual time=37972.784..152343.044 rows=298794 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=720923 read=651325 dirtied=252 written=17 -> Seq Scan on lineitem (cost=0.00..1838822.86 rows=32659387 width=12) (actual time=0.041..85073.479 rows=32364828 loops=1) Filter: (l_shipdate > '1995-03-15'::date) Rows Removed by Filter: 27680469 Buffers: shared hit=429524 read=649738 -> Hash (cost=612214.78..612214.78 rows=1468233 width=12) (actual time=37970.535..37970.535 rows=1459885 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 62730kB Buffers: shared hit=291399 read=1587 dirtied=252 written=17 -> Hash Join (cost=49665.89..612214.78 rows=1468233 width=12) (actual time=1668.856..36724.878 rows=1459885 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=291399 read=1587 dirtied=252 written=17 -> Seq Scan on orders (cost=0.00..446496.39 rows=7372376 width=16) (actual time=0.019..13451.506 rows=7297127 loops=1) Filter: (o_orderdate < '1995-03-15'::date) Rows Removed by Filter: 7717873 Buffers: shared hit=256124 read=436 dirtied=252 -> Hash (cost=45931.76..45931.76 rows=298730 width=4) (actual time=1668.620..1668.620 rows=299496 loops=1) Buckets: 32768 Batches: 1 Memory Usage: 10530kB Buffers: shared hit=35275 read=1151 written=17 -> Bitmap Heap Scan on customer (cost=6919.64..45931.76 rows=298730 width=4) (actual time=225.498..1499.039 rows=299496 loops=1) Recheck Cond: (c_mktsegment = 'FURNITURE'::bpchar) Buffers: shared hit=35275 read=1151 written=17 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6844.96 rows=298730 width=0) (actual time=208.361..208.361 rows=299496 loops=1) Index Cond: (c_mktsegment = 'FURNITURE'::bpchar) Buffers: shared read=1151 written=17 Total runtime: 153472.371 ms (35 rows) COMMIT; COMMIT