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

Prepared statements in wa-sqlite are not cached #681

Open
gorbak25 opened this issue Nov 18, 2023 · 2 comments
Open

Prepared statements in wa-sqlite are not cached #681

gorbak25 opened this issue Nov 18, 2023 · 2 comments
Labels
Improvement Created by Linear-GitHub Sync

Comments

@gorbak25
Copy link

prepared = await this.sqlite3.prepare_v2(

prepare_v2 generates a new query plan every time it's called. Consider keeping a cache of prepared statements.

@samwillis
Copy link
Contributor

Amusingly I've been looking a little into this this afternoon. 🤣

Compiled prepared statements include a query plan, and so we probably want to clear any cache whenever migrations are applied.

@gorbak25
Copy link
Author

@samwillis sqlite invalidates the query plan in prepared statements when the schema changes. The query plan will be regenerated when you will try to execute a query(calling sqlite_step). No special handling is required.

@kevin-dp kevin-dp added the Improvement Created by Linear-GitHub Sync label Nov 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Improvement Created by Linear-GitHub Sync
Projects
None yet
Development

No branches or pull requests

3 participants