All contributions

nodejs/node

Node.js

The JavaScript runtime built on V8 that runs servers, command line tools and front-end build pipelines. It ships a built-in node:sqlite module for working with SQLite databases.

Language
JavaScript
GitHub stars
123,955
Merged changes
1
Project site
nodejs.org

What we changed

We removed the sqlite3_clear_bindings() call that node:sqlite made before every statement run, which in SQLite 3.54 forced JOIN queries to be re-prepared. Omitted parameters still get NULL.

What this work shows

  • C++ bindings in Node.js
  • The SQLite C API and query plans
  • Query performance measurement
  • Tests with node:test
What was broken

JOIN queries re-prepared on every call

BindParams() called sqlite3_clear_bindings() before every statement run. Since SQLite 3.54 this invalidates the query plan, so a JOIN query was re-prepared on every get() and ran slower than on older Node.js versions.

How we fixed it

NULL only for omitted parameters

BindParams() now tracks which parameters were bound and sets NULL only on the rest, and ResetAndBindStatement() does not clear at all, since it always binds every parameter. With BigInt parameters a get() went from 3.4-4.3 µs to about 0.7 µs.

#66983

Merged change 1

  1. #66983 sqlite: avoid sqlite3_clear_bindings() before every run Merged 26 October 2026

What it taught us

A slow JavaScript query can have its cause as deep as a C++ binding and a behaviour change in SQLite, so you have to go down to that level and measure the effect. When we remove a shortcut such as clearing every parameter, we keep its guarantee: an omitted parameter is still NULL.

Other projects we write code for

Describe your project.

A free quote comes back within an hour during working hours.