Skip to content

sqlite: use shared-shape objects for result rows - #66385

Open
araujogui wants to merge 1 commit into
nodejs:mainfrom
araujogui:sqlite-shared-shape-rows
Open

araujogui wants to merge 1 commit into
nodejs:mainfrom
araujogui:sqlite-shared-shape-rows

Conversation

@araujogui

Copy link
Copy Markdown
Member

all(), get() and iterate() built each row with the Object::New() overload that takes names and values. That overload always returns a dictionary-mode object, so no two rows shared a map and every property read was a hash lookup.

Rows are now built from a DictionaryTemplate cached on the statement and invalidated on re-prepare. Rows keep their null prototype. Statements whose column names a template can't express (array indices, duplicates, non-ASCII names, which the template interns as Latin-1) or with more than 64 columns keep the previous path.

Adds benchmark/sqlite/sqlite-prepare-select-read.js, which reads every column of each row, since the existing benchmarks only measure building rows.

Fixes: #65799

`all()`, `get()` and `iterate()` built each row with the
`Object::New()` overload that takes names and values. That overload
always returns a dictionary-mode object, so no two rows shared a map
and every property read was a hash lookup.

Build rows from a `DictionaryTemplate` cached on the statement in place
of the column names, invalidated on re-prepare. Rows keep their null
prototype. Statements whose column names a template cannot express
(array indices, duplicates, non-ASCII names, which the template
interns as Latin-1) or with more than 64 columns keep the previous
path.

Add a benchmark that reads every column of each row, since the
existing ones only measure building rows.

Fixes: nodejs#65799
Assisted-by: Claude
Signed-off-by: Guilherme Araújo <arauujogui@gmail.com>
Copilot AI balanced review requested due to automatic review settings September 28, 2026 23:40
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/performance
  • @nodejs/sqlite

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. sqlite Issues and PRs related to the SQLite subsystem. labels Sep 28, 2026
@codecov

codecov Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.00000% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.35%. Comparing base (ae9c25a) to head (a61d7f8).
⚠️ Report is 13 commits behind head on main.

Files with missing lines Patch % Lines
src/node_sqlite.cc 85.00% 4 Missing and 5 partials ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #66385   +/-   ##
=======================================
  Coverage   90.35%   90.35%           
=======================================
  Files         792      792           
  Lines      275434   275467   +33     
  Branches    52781    52791   +10     
=======================================
+ Hits       248868   248910   +42     
- Misses      16978    16985    +7     
+ Partials     9588     9572   -16     
Files with missing lines Coverage Δ
src/node_sqlite.h 87.27% <ø> (ø)
src/node_sqlite.cc 82.16% <85.00%> (+0.19%) ⬆️

... and 28 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@araujogui araujogui added the needs-benchmark-ci PRs that need a benchmark CI run. label Sep 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. needs-benchmark-ci PRs that need a benchmark CI run. needs-ci PRs that need a full CI run. sqlite Issues and PRs related to the SQLite subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sqlite: remove the null prototype from result rows

3 participants