risinglight icon indicating copy to clipboard operation
risinglight copied to clipboard

optimizer: filter scan rule

Open crwen opened this issue 1 year ago • 2 comments

https://github.com/risinglightdb/risinglight/blob/0e4a8469e74d6e8a468b58e82df9ac0d0311b5e3/src/planner/rules/range.rs#L88-L100

Here's my understanding: When there are predicates on primary key, we should push them down to the storage layer. Is that right?

But it seems not to work when I execute statements like select pk from t where pk > 1. And the filter passed to scan function is always None. It looks like these:

> explain select a from t2 where a > 17;
Filter { cond: > { lhs: a, rhs: 17 }, cost: 68.4, rows: 20 }
└── Scan { table: t2, list: [ a ], filter: null, cost: 40, rows: 40 }

Maybe the true in "(scan ?table ?columns true)" should be replaced to null? Because it seems to work if I change it.

> explain select a from t2 where a > 17;
Scan { table: t2, list: [ a ], filter: > { lhs: a, rhs: 17 }, cost: 40, rows: 40 }

crwen avatar Feb 28 '24 10:02 crwen

maybe related: https://github.com/risinglightdb/risinglight/pull/795? But it's a known issue and if you want to fix that, please submit a pull request, thanks!

skyzh avatar Feb 28 '24 15:02 skyzh

It seems like that the filter is true by default, instead of null. So the solution may be like this in #795?

https://github.com/risinglightdb/risinglight/blob/cd03496eb2c0cb1fab7e43fa5738d42c091013fd/src/binder/table.rs#L60-L70

crwen avatar Feb 29 '24 11:02 crwen