Skip to content

[Feature] Add inlist2subquery rewrite rule#39

Open
TiNnNnnn wants to merge 5 commits into
OpenTenBase:8.0.30from
TiNnNnnn:gbp
Open

[Feature] Add inlist2subquery rewrite rule#39
TiNnNnnn wants to merge 5 commits into
OpenTenBase:8.0.30from
TiNnNnnn:gbp

Conversation

@TiNnNnnn

@TiNnNnnn TiNnNnnn commented Feb 4, 2026

Copy link
Copy Markdown

Add inlist2subquery rewrite rule.

Control parameters

two parameters were added:

in_predicate_conversion_enable 
in_predicate_conversion_threshold

simple example:

txsql> explain format = 'tree' SELECT * FROM t1 WHERE a IN (1,2,3,4);
+-------------------------------------------------------------------------------------------------+
| EXPLAIN                                                                                         |
+-------------------------------------------------------------------------------------------------+
| -> Filter: (t1.a in (1,2,3,4))  (cost=1.20 rows=2)
-> Table scan on t1  (cost=1.20 rows=2)
|
+-------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

After enable inlist2subquery rewrite rule:

txsql> explain format = 'tree' SELECT * FROM t1 WHERE a IN (1,2,3,4);
+-------------------------------------------------------------------------------------------------+
| EXPLAIN                                                                                         |
+-------------------------------------------------------------------------------------------------+
| -> Inner hash join (t1.a = tvc_0._col_1)  (cost=3.16 rows=1)
    -> Table scan on t1  (cost=0.35 rows=3)
    -> Hash
        -> Table scan on tvc_0  (cost=2.51..2.51 rows=1)
            -> Materialize  (cost=2.61..2.61 rows=1)
                -> Rows fetched before execution  (cost=0.00..0.00 rows=1)
 |
+-------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)


rewriter2

Performance Test Under Different size of in-list

simple_test

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@willhan123

Copy link
Copy Markdown
Collaborator

补充下相关测试用例

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants