Code Monkey home page Code Monkey logo

Comments (4)

haltcase avatar haltcase commented on May 18, 2024

Sounds good. This would be nice to add as createMany, with a few considerations:

  • Batching bulk inserts to configurable chunks (default = 100?)
  • sqlite doesn't support returning or output clauses. I worked around that in the design of create but I'm not sure that would translate to createMany, so the return value would be the number of rows, a boolean, or nothing.

from trilogy.

vazra avatar vazra commented on May 18, 2024
  • Batching bulk inserts to configurable chunks (default = 100?)

I think there are some limitations in sqlite bulk inserts, (eg: SQLITE ERROR, Toomany Variables) when you insert many rows at a time. Is there any basis for deciding the default chunk value to 100?

  • sqlite doesn't support returning or output clauses. I worked around that in the design of create but I'm not sure that would translate to createMany.

yeah, but I don't think that is required in bulk inserts.

from trilogy.

haltcase avatar haltcase commented on May 18, 2024

Is there any basis for deciding the default chunk value to 100?

None at all :) Probably 500 or even 1,000 is doable, I just don't know what the typical limit is and will have to look into it.

yeah, but I don't think that is required in bulk inserts.

Agreed, I just wanted to point out the return value would be different between create and createMany, but that'll be documented anyway.

from trilogy.

vazra avatar vazra commented on May 18, 2024

I just tried with a table with 4 columns , and fails at chunk of 240 with this, await db.knex<UserDocType>("users").insert(userArry), function. (Error : SQLITE ERROR, Toomany Variables).

When the chunks are smaller the net time taken for the query is more when compared with larger chunks.. Is it possible optimize the chunks count dynamically ? 🤔

from trilogy.

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.