Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eliminate remaining repeat_vars() calls #6359

Open
link2xt opened this issue Dec 22, 2024 · 0 comments · May be fixed by #6375
Open

Eliminate remaining repeat_vars() calls #6359

link2xt opened this issue Dec 22, 2024 · 0 comments · May be fixed by #6375
Assignees

Comments

@link2xt
Copy link
Collaborator

link2xt commented Dec 22, 2024

#6358 removes some uses of it, but other uses are difficult to eliminate.

#6355 proposes using temporary tables.
Instead of IN (?, ?, ?, ...) it is possible to open a transaction, create a temporary table, populate it with needed values in a loop, then select from it using IN (SELECT * FROM temp_table).

@iequidoo iequidoo self-assigned this Dec 29, 2024
iequidoo added a commit that referenced this issue Dec 31, 2024
Using `repeat_vars()` to generate SQL statements led to some of them having more than
`SQLITE_MAX_VARIABLE_NUMBER` parameters and thus failing, so let's get rid of this pattern. But
let's not optimise for now and just repeat executing an SQL statement in a loop, all the places
where `repeat_vars()` is used seem not performance-critical and containing functions execute other
SQL statements in loops. If needed, performance can be improved by preparing a statement and
executing it in a loop. An exception is `lookup_chat_or_create_adhoc_group()` where `repeat_vars()`
can't be replaced with a query loop, there we need to replace the `SELECT` query with a transaction
creating a temporary table which is used to perform the SELECT query then. Not good that a read
transaction is replaced with a write one, but `lookup_chat_or_create_adhoc_group()` is a heavy
function anyway which calls `create_adhoc_group()`, so this shouldn't affect performance a lot.
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 a pull request may close this issue.

2 participants