Comments (5)
This could be done. The only safe way of doing it would be to lock the database object upon creating an iterator, and unlocking the database object upon closing the iterator. As an example, trying to do any database operation inside the each()
callback currently results in a TypeError
. This would have to follow the same rules. Regardless, I can see the benefits of it.
Don't worry about opening a PR (although I accept PRs), I'm happy to implement this myself
from better-sqlite3.
This is next on my to-do list.
from better-sqlite3.
The Statement#iterate()
method is now supported as of v4.0.1.
from better-sqlite3.
Wow, did the iterate()
version cause that much of a performance boost (3.2x to 28.2x) ?
Is that only due to the fact we don't have to allocate an array ?
Well anyways, that's really awesome.
from better-sqlite3.
Wow, did the iterate() version cause that much of a performance boost (3.2x to 28.2x) ?
No, it's misleading, I apologize.
The old benchmark tested how well each library was able to read every row of a query in sequence, without interruptions. The new benchmark tests the same thing but with the possibility of interruptions. Iterators handle this very well, node-sqlite3 does not.
Essentially, since iterate()
is much more powerful than each()
, I felt it would be useful to benchmark what the equivalent power would cost in node-sqlite3. As it turns out, trying to replicate iterate()
in node-sqlite3 is extremely costly (28.2x more costly).
If you're iterating over every row of a query without interruptions or early termination (break
/return
/throw
), using all()
will still be slightly faster than iterate()
.
for (var row of stmt.all()) { ... } // faster
for (var row of stmt.iterate()) { ... } // slightly slower, but more flexible
from better-sqlite3.
Related Issues (20)
- Release 9.4.4 misses native artifacts HOT 4
- I can't install this package HOT 4
- BigInt values is queries incorrectly HOT 1
- Using drizzle-kit with better-sqlite3 in an electron application HOT 3
- Update SQLite to version 3.45.2 HOT 1
- 7.6.1 does not build on Linux HOT 4
- treatment of default column aliases when none are specified HOT 3
- nodejs v20.12.2 python.exe v3.12 VS2017/2022 don‘t’ install better-sqlite3, ask for help HOT 1
- Error: Error relocating /nodejs/app/node_modules/better-sqlite3/build/Release/better_sqlite3.node: _ZN2v89Exception10RangeErrorENS_5LocalINS_6StringEEE: symbol not found HOT 1
- Is there any solution to speed up the UPDATE command? HOT 1
- cannot start from a readonly path HOT 2
- Add prebuilds for Node.js 22 HOT 2
- Missing v10.0.0 prebuilt packages for darwin-x64 and linux-arm HOT 10
- Support parameters names in exactly the syntax in which they are used in the query HOT 2
- Better-sqlite3 not working on termux HOT 1
- Uncaught TypeError:Cannot read properties od null(reading 'access‘) at node_modules/better-sqlite3/lib/methods/backup.js HOT 2
- Prebuild compilation error on win32-arm64 + Electron v25 HOT 9
- vscode extension use better-sqlite3 error HOT 1
- No prebuilt binaries found (target=20.14.0 runtime=node arch=arm64 libc= platform=win32) HOT 3
- error /Users/praveen36singhq/Desktop/nimbold/bit-chainit-id/node_modules/better-sqlite3: Command failed. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from better-sqlite3.