db
The 20 best practices when using MySQL
Just came across this great article with 20 best practices when using MySQL: MySQL best practices.
Be sure to check them, the following items are in the article:
Optimize Your Queries For the Query Cache
LIMIT 1 When Getting a Unique Row
Get Suggestions with PROCEDURE ANALYSE()
Prepared Statements
Split the Big DELETE or INSERT Queries
Be Careful with Persistent Connections
And more [...]
Using TOP in MySQL queries
On the web I see a lot of questions of developers who are wanting to know how they can retrieve only the first N records in their queries.
The answer is simple, LIMIT
For example, if you only want to select the top 5 names from a names tables, use the following query:
SELECT `firstname`,`lastname`
FROM `names`
ORDER [...]