Skip to content

SqliteVec: re-use a single command for upserts - #55

Merged
adamsitnik merged 3 commits into
CommunityToolkit:mainfrom
rossdonald:reuse-command-for-insert
Oct 2, 2026
Merged

adamsitnik merged 3 commits into
CommunityToolkit:mainfrom
rossdonald:reuse-command-for-insert

Conversation

@rossdonald

Copy link
Copy Markdown
Contributor

Changes upserts to use a single command for inserts so SQL text for an insert is stable across records and the provider's per-command prepared statement cache and parameter bindings can be reused, and only values are re-bound per record.
Fixes #54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Remove the unused test declarations causing CS0219 and bump the provider package version.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 High severity

Open (1)
What changed in this PR

Refactors SqliteVec upserts to reuse stable single-row commands and rebind values per record.

Changes:

  • Reuses prepared insert commands.
  • Separates returning and non-returning upsert paths.
  • Expands command-builder tests for parameter rebinding and vector handling.
File Summary
MEVD/​test/​SqliteVec.UnitTests/​SqliteCommandBuilderTests.cs Tests updated command and parameter-binding behavior; unused declarations cause CS0219.
MEVD/​src/​SqliteVec/​SqliteCommandBuilder.cs Builds stable insert SQL and binds values dynamically; package version should be bumped.
MEVD/​src/​SqliteVec/​SqliteCollection.cs Reuses insert commands during upserts; package version should be bumped.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread MEVD/test/SqliteVec.UnitTests/SqliteCommandBuilderTests.cs

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Bump the provider package version for the implementation changes.

Review effort: Lite
Findings: None

Resolved since last review (1)
Previously missed (1)

In code that hasn't changed since last review

Low severity Update provider version for changed C# code

MEVD/​src/​SqliteVec/​SqliteCommandBuilder.cs:120

This PR changes provider implementation files under MEVD/src/SqliteVec, but MEVD/src/SqliteVec/SqliteVec.csproj still declares version 1.0.2-preview. The repository release guidance requires a SemVer update for every such C# change; please bump the provider version so this fix can be published under a distinct package/tag version.

@adamsitnik adamsitnik left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rossdonald thanks for another great contribution!

The code looks good, I found only few minor things that could be addressed before we merge, PTAL at my comments.

Comment thread MEVD/src/SqliteVec/SqliteCollection.cs Outdated
Comment thread MEVD/src/SqliteVec/SqliteCollection.cs Outdated
Comment thread MEVD/test/SqliteVec.UnitTests/SqliteCommandBuilderTests.cs Outdated
@rossdonald

Copy link
Copy Markdown
Contributor Author

Thanks for the feedback, looks good. I will update in a few days as I am travelling

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Two moderate issues and one versioning nit remain unresolved.

Review effort: Lite
Findings: 1 Low severity

Open (1)

Comment thread MEVD/src/SqliteVec/SqliteCollection.cs

@adamsitnik adamsitnik left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks great, thank you for another awesome contribution @rossdonald !

Batch size Base mean PR mean Time change Base allocation PR allocation Allocation change
1 1.149 ms 1.165 ms 1.4% slower (noise-level) 12.84 KB 12.47 KB 2.9% lower
10 1.354 ms 1.260 ms 6.9% faster 72.51 KB 29.98 KB 58.7% lower
100 5.927 ms 2.054 ms 65.3% faster 3178.35 KB 205.05 KB 93.5% lower

@adamsitnik
adamsitnik merged commit c3ed414 into CommunityToolkit:main Oct 2, 2026
17 checks passed
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 this pull request may close these issues.

SqliteVec BuildInsertCommand is slow as it does not reuse a single command for inserts

3 participants