Skip to content

Add support for prepared statement #322

Closed
@lbe

Description

@lbe

Is your feature request related to a problem? Please describe.
I would like to use Prepare and PrepareContext with Jet queries to realize the performance benefit.

I have benchmarked hand written SQL using the native features of database/sql using mattn/go-sqlite3. When using a combination of: WAL, Sync=Normal, Transactions and Prepared Statements I see a performance increase of 2.5 - 3 times that of Jet with WAL, Sync=Normal and Transactions.

On one off queries, the performance penalty is insignificant. It is significant when performing batch inserts or updates even when using upsert patterns. I have used pprof to investigate my code and find that almost all time is spent within sqlite CGo regardless of which implementation I use.

Describe the solution you'd like
I would like to have a way to instruct a query built with Jet to create a prepared statement on the first call of a query and then reuse the prepared statement for any subsequent execution. The syntax could be created by extending the existing verbs, for example, JetStmt.Exec to JetStmt.ExecPrepared and JetStmt.ExecPreparedContext.

I wish my Go skills were such that I could prepare a pull request or at least mock up a potential implementation. Unfortunately they are not.

Thank you for Jet as is and thank you for considering this request.

lbe

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions