sqlite3 icon indicating copy to clipboard operation
sqlite3 copied to clipboard

Rewrite for better performance & API

Open DjDeveloperr opened this issue 3 years ago • 5 comments

Goals:

  • Optimize for fastapi calls
  • Take inspiration from better-sqlite3 (Node.js) API as it is simple and concise

Previously:

image

Now:

image

DjDeveloperr avatar Aug 21 '22 14:08 DjDeveloperr

Bun is caching column names / count and does no validation if you alter schema from another process. It has an unfair advantage here, let's not choose the bad actor as the baseline.

littledivy avatar Aug 21 '22 16:08 littledivy

One thing I noticed about the Bun and the better-sqlite3 implementations is that they don't make you call sqlite3_finalize for prepared statements. That's because they use destructors in the C++ implementations [0] [1].

I know we don't have destructors in JS, but I'm wondering if you would consider using something like the FinalizationRegistry API to do this?

[0] Bun JSSQLStatement destructor

[1] better-sqlite3 Statement destructor

waynebloss avatar Aug 25 '22 13:08 waynebloss

I know we don't have destructors in JS, but I'm wondering if you would consider using something like the FinalizationRegistry API to do this?

Yup - good idea, added it now

DjDeveloperr avatar Aug 25 '22 14:08 DjDeveloperr

Had to revert finalizer... causing unexpected exits during tests weirdly only on Windows CI

DjDeveloperr avatar Aug 25 '22 14:08 DjDeveloperr

Managed to fix finalizer

DjDeveloperr avatar Aug 28 '22 18:08 DjDeveloperr