Answer the question
In order to leave comments, you need to log in
Which is better: a request queue or one, but a large one?
The request/s are formed in a loop, parsing the associative array, which is better - to form one request, or to execute your own for each new line?
Answer the question
In order to leave comments, you need to log in
What requests are we talking about? Splitting with a semicolon?
I can say for sure that a multiline INSERT (one INSERT with several rows) is much faster than several separate INSERTs.
In most cases, this issue is saving on matches.
In this case, a large query will be simple and easy to execute, which means it will be fast.
Many small requests will most likely not reach the database at all, and the result will be taken from the cache, which means it will also be executed quickly.
Do what works best for you, and save the desire to optimize for places where it's really needed.
Either it doesn’t matter at all, or something in between is optimal - one request for every 100-1000 iterations.
One request.
This is the most common (and thankfully the easiest to fix) thing to do when doing something like foreach() mysql_query; that with just something even with 100 array elements results in 100 queries. Horror fear and trembling.
in a transaction is faster - that's why it is a transaction.
instead of 100 update, by the way, sometimes you can pervert and get by with one multiline insert… on duplicate key update
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question