electric icon indicating copy to clipboard operation
electric copied to clipboard

Prepared statements in wa-sqlite are not cached

Open gorbak25 opened this issue 1 year ago • 2 comments

https://github.com/electric-sql/electric/blob/d385d3cf7eb4c8822afefdd6173fad7feb71712a/clients/typescript/src/drivers/wa-sqlite/database.ts#L45

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

gorbak25 avatar Nov 18 '23 18:11 gorbak25

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.

samwillis avatar Nov 18 '23 19:11 samwillis

@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.

gorbak25 avatar Nov 19 '23 14:11 gorbak25

👋 we've been working the last month on a rebuild of the Electric server over at a temporary repo https://github.com/electric-sql/electric-next/

You can read more about why we made the decision at https://next.electric-sql.com/about

We're really excited about all the new possibilities the new server brings and we hope you'll check it out soon and give us your feedback.

We're now moving the temporary repo back here. As part of that migration we're closing all the old issues and PRs. We really appreciate you taking the time to investigate and report this issue!

KyleAMathews avatar Aug 06 '24 13:08 KyleAMathews