limbo/core
Jussi Saurio c4548b51f1 Merge 'Optimization: lift common subexpressions from OR terms' from Jussi Saurio
```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
		)
	);
```
This allows Limbo's optimizer to 1. recognize `p_partkey=l_partkey` as
an index constraint on `part`, and 2. filter out `lineitem` rows before
joining. With this optimization, Limbo completes TPC-H `19.sql` nearly
as fast as SQLite on my machine. Without it, Limbo takes forever.
This branch: `939ms`
Main: `uh, i started running it a few minutes ago and it hasnt finished,
and i dont feel like waiting i guess`

Reviewed-by: Pere Diaz Bou <pere-altea@homail.com>

Closes #1520
2025-05-20 14:33:49 +03:00
..
benches add bench for select count 2025-05-10 22:23:01 -03:00
ext io/linux: make syscallio the default (io_uring is really slow) 2025-04-10 13:32:26 +03:00
functions Rename OwnedValue -> Value 2025-05-15 09:59:46 +03:00
io shared lock on file and throw ReadOnly error in transaction 2025-05-02 16:30:48 -03:00
json Rename OwnedValue -> Value 2025-05-15 09:59:46 +03:00
mvcc clippy 2025-03-25 17:13:31 +02:00
numeric numeric types overhaul 2025-04-23 08:34:58 -03:00
storage Merge 'Add support for DISTINCT aggregate functions' from Jussi Saurio 2025-05-20 13:58:57 +03:00
translate Merge 'Optimization: lift common subexpressions from OR terms' from Jussi Saurio 2025-05-20 14:33:49 +03:00
vdbe Merge 'Add support for DISTINCT aggregate functions' from Jussi Saurio 2025-05-20 13:58:57 +03:00
vector Rename OwnedValue -> Value 2025-05-15 09:59:46 +03:00
build.rs
Cargo.toml Create CollationSeq enum and functions. Move strum to workspace dependency to avoid version mismatch with Parser 2025-05-19 15:22:14 -03:00
error.rs shared lock on file and throw ReadOnly error in transaction 2025-05-02 16:30:48 -03:00
fast_lock.rs Remove unlock method and move it to guard's drop. 2025-03-27 18:45:05 +05:30
function.rs add Func::is_deterministic() 2025-04-24 11:05:21 +03:00
info.rs
lib.rs Extract page cache size constant and bump to 2k 2025-05-16 15:40:19 +03:00
numeric.rs Rename OwnedValue -> Value 2025-05-15 09:59:46 +03:00
parameters.rs Consolidate match case in parameters push to handle all anonymous params in one case 2025-05-13 14:42:12 -04:00
pseudo.rs wip 2025-03-29 22:02:49 +01:00
result.rs
schema.rs Merge 'refactor: replace Operation::Subquery with Table::FromClauseSubquery' from Jussi Saurio 2025-05-20 14:31:42 +03:00
types.rs refactor BtreeCursor and Sorter to accept Vec of collations 2025-05-19 15:22:55 -03:00
util.rs Added collation to create table columns 2025-05-19 15:22:14 -03:00