We're updating the issue view to help you get more done. 

Add support for IN-lists padding to better reuse cached statements

Description

As described in this Twitter thread, we could add a new feature which generates power-of-2 IN lists so we get a better chance of reusing the execution plan, especially on Oracle and SQL Server.

So, let's assume we have the following 3 SELECT queries executed:

1 2 3 SELECT * FROM my_table where id IN (1, 2, 3); SELECT * FROM my_table where id IN (4, 6, 7); SELECT * FROM my_table where id IN (7, 8, 9, 10);

We can rewrite them as:

1 2 3 SELECT * FROM my_table where id IN (1, 2, 3, 3); SELECT * FROM my_table where id IN (4, 6, 7, 7); SELECT * FROM my_table where id IN (7, 8, 9, 10);

This way we reuse the same cached statement:

1 SELECT * FROM my_table where id IN (?, ?, ?, ?);

Environment

None

Status

Assignee

Vlad Mihalcea

Reporter

Vlad Mihalcea

Labels

None

Worked in

None

Feedback Requested

None

Feedback Requested By

None

backPortable

None

Community Help Wanted

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

backportReEvaluate

None

Fix versions

Priority

Major