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 = 'AUTOMOBILE' and c_custkey = o_custkey and l_orderkey = o_orderkey and o_orderdate < date '1995-03-04' and l_shipdate > date '1995-03-04' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2772234.41..2772234.44 rows=10 width=20) (actual time=74350.708..74350.713 rows=10 loops=1) Buffers: shared hit=656853 read=714076 dirtied=253 written=1 -> Sort (cost=2772234.41..2780252.04 rows=3207051 width=20) (actual time=74350.703..74350.707 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=656853 read=714076 dirtied=253 written=1 -> HashAggregate (cost=2670860.68..2702931.19 rows=3207051 width=20) (actual time=74231.300..74322.419 rows=113922 loops=1) Buffers: shared hit=656847 read=714076 dirtied=253 written=1 -> Hash Join (cost=629803.76..2622754.92 rows=3207051 width=20) (actual time=22384.479..73764.041 rows=300623 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=656847 read=714076 dirtied=253 written=1 -> Seq Scan on lineitem (cost=0.00..1836996.19 rows=33035857 width=12) (actual time=0.039..27502.400 rows=32640011 loops=1) Filter: (l_shipdate > '1995-03-04'::date) Rows Removed by Filter: 27404983 Buffers: shared hit=365265 read=712923 written=1 -> Hash (cost=611383.32..611383.32 rows=1473635 width=12) (actual time=22382.176..22382.176 rows=1445399 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 62107kB Buffers: shared hit=291582 read=1153 dirtied=253 -> Hash Join (cost=49802.57..611383.32 rows=1473635 width=12) (actual time=503.113..21405.118 rows=1445399 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=291582 read=1153 dirtied=253 -> Seq Scan on orders (cost=0.00..446056.09 rows=7330059 width=16) (actual time=0.010..5132.894 rows=7228039 loops=1) Filter: (o_orderdate < '1995-03-04'::date) Rows Removed by Filter: 7786961 Buffers: shared hit=256307 dirtied=253 -> Hash (cost=46033.07..46033.07 rows=301560 width=4) (actual time=502.866..502.866 rows=300036 loops=1) Buckets: 32768 Batches: 1 Memory Usage: 10549kB Buffers: shared hit=35275 read=1153 -> Bitmap Heap Scan on customer (cost=6985.57..46033.07 rows=301560 width=4) (actual time=71.373..409.253 rows=300036 loops=1) Recheck Cond: (c_mktsegment = 'AUTOMOBILE'::bpchar) Buffers: shared hit=35275 read=1153 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6910.18 rows=301560 width=0) (actual time=62.124..62.124 rows=300036 loops=1) Index Cond: (c_mktsegment = 'AUTOMOBILE'::bpchar) Buffers: shared read=1153 Total runtime: 74392.256 ms (35 rows) COMMIT; COMMIT