GithubHelp home page GithubHelp logo

Comments (8)

DjDeveloperr avatar DjDeveloperr commented on June 7, 2024 1

Fix released in 0.2.5

from sqlite3.

iuioiua avatar iuioiua commented on June 7, 2024 1

Legend! Thank you 🙏🏾

from sqlite3.

DjDeveloperr avatar DjDeveloperr commented on June 7, 2024

I think that's because it's parsing all integer type columns as 32-bit integers. I will fix this asap

from sqlite3.

Hexagon avatar Hexagon commented on June 7, 2024

@DjDeveloperr

This problem seem to be back in 0.8.2

CLI:
SELECT MAX(period) FROM spotprice
1678572000000

Deno sqlite3 0.8.3
prepare('SELECT MAX(period) FROM spotprice').values() // also tested with .all(), also tested with <number> and <bigint> like in the test cases, to no avail
[ [ -760212736 ] ]

from sqlite3.

DjDeveloperr avatar DjDeveloperr commented on June 7, 2024

@Hexagon See doc.md. It's a performance optimization to always prefer 32-bit integers over 64-bit. SQLite API does not differentiate between both in value type, hence the preference.

If you want to serialize as 64 bit either set int64: true in DB options or temporarily set it in DB's property to avoid performance deopt.

Performance issue is because the FFI API cannot use BigInts in fast path, but this may change in future, so both options will become performant.

from sqlite3.

Hexagon avatar Hexagon commented on June 7, 2024

@DjDeveloperr Sorry about that! I searched the docs and googled and somehow missed that the option were listed at top of documentation 😅

However, this got me thinking. Is there really any performance gain from having this error prone option defaulted to int32?

Afaik both sqlite and javascript handle 64bit integers (and nothing above that) ootb. Wouldn't it be possible to change

if (ty === SQLITE_INTEGER && !int64) return sqlite3_column_int(handle, i);

to

if (ty === SQLITE_INTEGER) return sqlite3_column_int64(handle, i);

and drop this clause (containing a possibly slow bignum check) altogether

case SQLITE_INTEGER: {

from sqlite3.

DjDeveloperr avatar DjDeveloperr commented on June 7, 2024

sqlite3_column_int is faster than sqlite3_column_int64 because the latter makes a heap allocation to store the result value as 64 bit integers are not directly supported by V8 Fast API yet. It's just an implementation detail behind the FFI API, which is likely going to change in future as returning 64 bit numbers as BigInts may become possible via Fast API, at least that's the plan.

from sqlite3.

Hexagon avatar Hexagon commented on June 7, 2024

I see, thanks for taking time to answer 👍

from sqlite3.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.