-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Description
This is for SQLite used together with Bun.
I've got a hot path where I run many many SQLite queries at once. It's hot enough that calling db.prepare for each invocation (which is what the codegen emits right now) ends up adding massive overhead.
I'm wondering, would it be possible to provide some sort solution/escape hatch for this, so that all/some queries are always prepared just once? OTOH, I can think of a couple of ways to fix this:
- Always call prepare on the query as soon as the query file is loaded. Then always use the prepared query and never call prepare again. This is probably a bit dangerous because it creates boot overhead that you can't control.
- Generate a "prepare" function into the generated files, that when called prepares the query locally in the file and switches so the query always uses the prepared one from that point on.
- Add an arg to the current execution functions that let you toggle forcing the query to be prepared once before running it. Essentially the above, but behind an option.
For dynamic queries where the query is not known statically I assume some more clever solution is needed, so they probably shouldn't be prepared by default. But for the rest, maybe one of the above could work. What do you think?
Thanks for this great lib btw.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels