Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL queries - how expensive are they really?

I've heard that mysql queries are very expensive, and that you should avoid at all costs making too many of them.

I'm developing a site that will be used by quite a few people, and I'm wondering:

How expensive are mysql queries actually? If I have 400,000 people in my database, how expensive is it to query it for one of them?

How close attention do I need to pay that I don't make too many queries per client request?


Edit: TomTom couldn't be more correct with his answer. According to perormance tests on the sites linked to in the comments (and a couple sites I found through a "mysql queries per second" search), I won't be encountering problems for quite a while - mysql can do thousands of queries per second with a remote server.

like image 652
Cam Avatar asked Mar 18 '10 11:03

Cam


People also ask

What is MySQL query cost?

One component you should look at is “query cost.” Query cost refers to how expensive MySQL considers this particular query in terms of the overall cost of query execution, and is based on many different factors. Simple queries generally have query cost of less than 1,000.

How many queries are there in a database?

Five types of SQL queries are 1) Data Definition Language (DDL) 2) Data Manipulation Language (DML) 3) Data Control Language(DCL) 4) Transaction Control Language(TCL) and, 5) Data Query Language (DQL)

Is MySQL the fastest?

Ultimately, speed will depend on the way you're using the database. PostgreSQL is known to be faster for handling massive data sets, complicated queries, and read-write operations. Meanwhile, MySQL is known to be faster with read-only commands.


1 Answers

Just ignore it. Seriously. If you need data, you need data. Make sure your queries are reasonable fast (i.e. proper indices). Get a proper server for handling the load. Use output caching as makes sense, start caching data once you know where you actually HAVE a problem.

like image 158
TomTom Avatar answered Nov 09 '22 16:11

TomTom