Coder Social home page Coder Social logo

Comments (3)

peter279k avatar peter279k commented on August 22, 2024

My question is very similar with this, but it seems that using strlen cannot get current query size to compare to max allowed packet size.

from db.

BenMorel avatar BenMorel commented on August 22, 2024

Hi, it will be hard to implement this feature as I don't think the packet size calculation is easy (the packet is probably bigger than the length of the query and the parameters). I would suggest you calculate the total length of your parameters, multiply this by the number of inserts per query you're planning to use, and take some margin (like half the max packet size) to be on the safe side.

Then adjust the max_allowed_packet or the inserts per query accordingly!

from db.

peter279k avatar peter279k commented on August 22, 2024

Hi @BenMorel, thanks for your reply.

You're right. It's hard to calculate current query size. Even use the strlen function to calculate query size in PHP is not correct.

I think the only way is like you suggest.

Using the half length of max_allowed_packet size to ensure that every bulk insertion queries will be worked without Got a packet bigger than 'max_allowed_packet' bytes message :).

from db.

Related Issues (5)

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.