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-03' and l_shipdate > date '1995-03-03' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2764718.09..2764718.12 rows=10 width=20) (actual time=66345.422..66345.427 rows=10 loops=1) Buffers: shared hit=742119 read=626162 written=1257 -> Sort (cost=2764718.09..2772662.42 rows=3177733 width=20) (actual time=66345.418..66345.422 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=742119 read=626162 written=1257 -> HashAggregate (cost=2664271.09..2696048.42 rows=3177733 width=20) (actual time=66252.411..66324.664 rows=113889 loops=1) Buffers: shared hit=742113 read=626162 written=1257 -> Hash Join (cost=627833.42..2616605.10 rows=3177733 width=20) (actual time=24308.518..65896.713 rows=300529 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=742113 read=626162 written=1257 -> Seq Scan on lineitem (cost=0.00..1833355.58 rows=32970340 width=12) (actual time=0.066..21384.431 rows=32664054 loops=1) Filter: (l_shipdate > '1995-03-03'::date) Rows Removed by Filter: 27380122 Buffers: shared hit=486981 read=589065 written=18 -> Hash (cost=609581.21..609581.21 rows=1460177 width=12) (actual time=24306.351..24306.351 rows=1444241 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 62058kB Buffers: shared hit=255132 read=37097 written=1239 -> Hash Join (cost=49783.51..609581.21 rows=1460177 width=12) (actual time=902.014..23105.941 rows=1444241 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=255132 read=37097 written=1239 -> Seq Scan on orders (cost=0.00..445175.49 rows=7274214 width=16) (actual time=0.012..5566.412 rows=7221951 loops=1) Filter: (o_orderdate < '1995-03-03'::date) Rows Removed by Filter: 7793049 Buffers: shared hit=255130 read=671 written=111 -> Hash (cost=46019.76..46019.76 rows=301100 width=4) (actual time=901.797..901.797 rows=300036 loops=1) Buckets: 32768 Batches: 1 Memory Usage: 10549kB Buffers: shared hit=2 read=36426 written=1128 -> Bitmap Heap Scan on customer (cost=6978.01..46019.76 rows=301100 width=4) (actual time=72.784..772.156 rows=300036 loops=1) Recheck Cond: (c_mktsegment = 'AUTOMOBILE'::bpchar) Buffers: shared hit=2 read=36426 written=1128 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6902.73 rows=301100 width=0) (actual time=63.842..63.842 rows=300036 loops=1) Index Cond: (c_mktsegment = 'AUTOMOBILE'::bpchar) Buffers: shared read=1153 written=35 Total runtime: 66390.355 ms (35 rows) COMMIT; COMMIT