Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How many queries are too many?

Tags:

I have to run one time 10 mysql queries for one person in one page. Is it very bad? I have quite good hosting, but still, can it break or something? Thank you very much.

like image 607
good_evening Avatar asked Mar 05 '11 12:03

good_evening


People also ask

How many SQL queries is too much?

Executive Summary. 200 SQL statements per webpage is excessive for client/server database engines like MySQL, PostgreSQL, or SQL Server.

How many queries can a database have per page?

If your database service only allows you to make simple SQL queries, less than 20 queries would be fine for a small, common webpage, but if it's the webpage for your university or a decision taking support application, 60 may not be enough.

How long should DB queries take?

The query takes 20 to 500 ms (or sometimes more) depending on the system and the amount of data. The performance of the database or the database server has a significant influence on the speed. A tip: Test your system using the demo license of the Connector to get an indication of the performance of your components.

How many queries MySQL can handle?

MySQL can run more than 50,000 simple queries per second on commodity server hardware and over 2,000 queries per second from a single correspondent on a Gigabit network, so running multiple queries isn't necessarily such a bad thing.


2 Answers

Drupal sites typically make anywhere from 150 to 400+ queries per request. The total time spent querying the database is still under 1s - it's not the number that kills the server, but the quality/complexity of the queries (and possibly the size of the dataset they search through).

I can't tell what queries you're talking about but on most sites 10 is not much at all.

If you're concerned with performance, you can always see how long your queries take to execute in a database management program, such as MySQL Workbench.

like image 183
mingos Avatar answered Sep 18 '22 21:09

mingos


10 fast queries can be better than 1 slow one. Define what's acceptable in terms of response time, throughput, in normal and peek traffic conditions, and measure if these 10 queries are a problem or not (i.e. don't respect your expectations).

If they are, then try to change your design and find a better solution.

like image 43
JB Nizet Avatar answered Sep 18 '22 21:09

JB Nizet