Take the 2-minute tour ×

Is it a good practice sleep() in database calls ?.

Im talking about calls like insert new users, show products, etc, in a website with heavy traffic.

if you think it is a good or bad idea, could explain their point of view?, to know the reasons why you think so.

Thanks for participating!

share|improve this question
It depends of where and why you want to use it. –  Norbert Orzechowicz Sep 21 '12 at 19:16
Questions which take the form of polls, or for which the answers are matters of opinion, really don't make sense on SO. –  Ollie Jones Sep 21 '12 at 19:21
Would you mind to explain how you will put the sleep() in the database call? I always thought that SQL statements are sent from PHP to the database and from this point on you cannot to anything about it that would modify the database processing. The next step in PHP is then to take the answer from the database. But where exactly do you wanna sleep? –  BurninLeo Sep 21 '12 at 19:23
db call -> sleep().It is common practice in some user registries. –  Stefan Luv Sep 21 '12 at 19:25
No - Why? Decrease the performance and increase the frustration. A database should be responsive (like a web site). Just fix the performance issue rather that slowing things down. –  Ed Heal Sep 21 '12 at 19:27
add comment

closed as not constructive by Ollie Jones, andrewsi, Florent, Ashish Gupta, tereško Sep 21 '12 at 22:24


1 Answer

If you're sleeping between SQL statements to allow for replication, this may be a valid reason, though unreliable.

Sleeping between statements does not relieve contention, it just delays it. It would be like having a four way stop where each stop sign had another stop sign before it. The first stop sign does not solve the issue of the four way stop. The four way stop must still occur.

Generally, we expect MySQL server to manage the jobs for us. It does a good job with multiple users. To keep MySQL server at its max efficiency, we'd want to keep it busy.

Unused clock cycles, in reality, are being wasted. In order to get a return on the hardware investment, we should keep it busy, not waiting.

share|improve this answer
Do you think that a database designer or the programmers that wrote that database have not considered the implications of replication and have gained the experience? Then a person comes along and thinks they know better? Anyway why not let the database get on with its job as long as you have designed it corrected/efficently? –  Ed Heal Sep 21 '12 at 19:40
add comment
