limbo/perf/tpc-h/queries
Jussi Saurio 6790b7479c Optimization: lift common subexpressions from OR terms
```sql
-- This PR does effectively this transformation:

select
	sum(l_extendedprice* (1 - l_discount)) as revenue
from
	lineitem,
	part
where
	(
		p_partkey = l_partkey
		and p_brand = 'Brand#22'
		and p_container in ('SM CASE', 'SM BOX', 'SM PACK', 'SM PKG')
		and l_quantity >= 8 and l_quantity <= 8 + 10
		and p_size between 1 and 5
		and l_shipmode in ('AIR', 'AIR REG')
		and l_shipinstruct = 'DELIVER IN PERSON'
	)
	or
	(
		p_partkey = l_partkey
		and p_brand = 'Brand#23'
		and p_container in ('MED BAG', 'MED BOX', 'MED PKG', 'MED PACK')
		and l_quantity >= 10 and l_quantity <= 10 + 10
		and p_size between 1 and 10
		and l_shipmode in ('AIR', 'AIR REG')
		and l_shipinstruct = 'DELIVER IN PERSON'
	)
	or
	(
		p_partkey = l_partkey
		and p_brand = 'Brand#12'
		and p_container in ('LG CASE', 'LG BOX', 'LG PACK', 'LG PKG')
		and l_quantity >= 24 and l_quantity <= 24 + 10
		and p_size between 1 and 15
		and l_shipmode in ('AIR', 'AIR REG')
		and l_shipinstruct = 'DELIVER IN PERSON'
	);

-- Same query with common conjuncts (ANDs) extracted:
select
	sum(l_extendedprice* (1 - l_discount)) as revenue
from
	lineitem,
	part
where
	p_partkey = l_partkey
	and l_shipmode in ('AIR', 'AIR REG')
	and l_shipinstruct = 'DELIVER IN PERSON'
	and (
		(
			p_brand = 'Brand#22'
			and p_container in ('SM CASE', 'SM BOX', 'SM PACK', 'SM PKG')
			and l_quantity >= 8 and l_quantity <= 8 + 10
			and p_size between 1 and 5
		)
		or
		(
			p_brand = 'Brand#23'
			and p_container in ('MED BAG', 'MED BOX', 'MED PKG', 'MED PACK')
			and l_quantity >= 10 and l_quantity <= 10 + 10
			and p_size between 1 and 10
		)
		or
		(
			p_brand = 'Brand#12'
			and p_container in ('LG CASE', 'LG BOX', 'LG PACK', 'LG PKG')
			and l_quantity >= 24 and l_quantity <= 24 + 10
			and p_size between 1 and 15
		)
	);
```
2025-05-20 14:25:15 +03:00
..
1.sql perf/ci: add basic tpc-h benchmark 2025-05-15 17:09:49 +03:00
2.sql perf/ci: add basic tpc-h benchmark 2025-05-15 17:09:49 +03:00
3.sql perf/ci: add basic tpc-h benchmark 2025-05-15 17:09:49 +03:00
4.sql perf/ci: add basic tpc-h benchmark 2025-05-15 17:09:49 +03:00
5.sql perf/ci: add basic tpc-h benchmark 2025-05-15 17:09:49 +03:00
6.sql perf/ci: add basic tpc-h benchmark 2025-05-15 17:09:49 +03:00
7.sql perf/ci: add basic tpc-h benchmark 2025-05-15 17:09:49 +03:00
8.sql perf/ci: add basic tpc-h benchmark 2025-05-15 17:09:49 +03:00
9.sql perf/ci: add basic tpc-h benchmark 2025-05-15 17:09:49 +03:00
10.sql perf/ci: add basic tpc-h benchmark 2025-05-15 17:09:49 +03:00
11.sql perf/ci: add basic tpc-h benchmark 2025-05-15 17:09:49 +03:00
12.sql perf/ci: add basic tpc-h benchmark 2025-05-15 17:09:49 +03:00
13.sql perf/ci: add basic tpc-h benchmark 2025-05-15 17:09:49 +03:00
14.sql perf/ci: add basic tpc-h benchmark 2025-05-15 17:09:49 +03:00
15.sql perf/ci: add basic tpc-h benchmark 2025-05-15 17:09:49 +03:00
16.sql perf/ci: add basic tpc-h benchmark 2025-05-15 17:09:49 +03:00
17.sql perf/ci: add basic tpc-h benchmark 2025-05-15 17:09:49 +03:00
18.sql perf/ci: add basic tpc-h benchmark 2025-05-15 17:09:49 +03:00
19.sql Optimization: lift common subexpressions from OR terms 2025-05-20 14:25:15 +03:00
20.sql perf/ci: add basic tpc-h benchmark 2025-05-15 17:09:49 +03:00
21.sql perf/ci: add basic tpc-h benchmark 2025-05-15 17:09:49 +03:00
22.sql perf/ci: add basic tpc-h benchmark 2025-05-15 17:09:49 +03:00