Coding Guidelines in SQL Queries Important for Query Cache
, Monday, April 6, 2009It's important to also use coding guidelines in your SQL queries you write for example inside your PHP Code. Most MySQL SELECT queries are cached and since MySQL 5.1.17 also prepared statements are cache (with some exceptions).
For SQL query caching to work it's important that a query is exactly the same (Byte by Byte) as the one before. As an example the following three queries are all different for the query cache even if they return exactly the same result:
SELECT * FROM tbl_name
Select * From tbl_name
SELECT * FROM tbl_name
In the last example we have some more spaces. So be careful when you write your SQL queries.


