Friday, April 6, 2012

Speeding up MySQL Queries for faster performance.

Speeding up MySQL Queries for faster performance.
MySQL Queries Can Really Kill Your Web Server. Yes its true that writing buggy SQL queries can result in a lot of server cpu usage. Many webmasters face this problem and they think that their service provider is not good and blah blah.

if you are in one of them or your server is getting overloaded because of MySQL then i will suggest you to look at below tweaks that can help in reducing the cpu usage of a script.

1) Avoid unnecessary UPDATE queries.

2) An example of fast and slow SELECT sql query:
Faster Query: mysql_query("SELECT id,name,title from table_name");
Slower Query: mysql_query("SELECT * from table_name");

3) Avoid using functions with SQL queries.
Like: mysql_query("SELECT id from table_name where time=time()");
(note: the above query is just for explanation.)
Similarly there are a lot of ways to improve and reduce the server load by optimizing the SQL queries.

No comments:

Post a Comment