Tips to write an efficient and fast Mysql Query

Note: I am updating this tutorial frequently when I see any new tips to speed up mysql query. So please bookmark this article for future use.


These are the following tips given below:

(1) Always use persistent database connection to avoid connection overhead. By using persistent database connection, you can avoid every time connection whenever you want any database operation.

(2) While creating table, you should keep the entire column as NOT NULL. Making the entire column as NOT NULL will avoid NULL entry into the column.

(3) Always make sure that every table must have a Primary Key. Primary key is very essential for mysql operation.

(4) While writing JOIN Query, Make sure that both columns should have same datatypes.

(5) Always use LIMIT in SELECT query to limit your data retrieval. It will make fast your query.

(6) Never use ( * ) in SELECT query, Try to use the desired column name.

(7) Increase your database buffer size.

(8) We should avoid UNION, HAVING in our query because it can slow our query.

(9) While writing ORDER BY, We should write column name instead of writing any function like RAND, COUNT. It will slow our query.

Share this Article on Social Media

All of my Scripts are ready to customized as per your requirement. Feel free to contact for script customization.

Contact me at

"Note : It will be charged as per your customization requirement :)"

Get Updates, Scripts & Other Tutorials to Directly to your Email

Over 20000+ Happy Readers already subscribed. (We don't send spam email). Every email subscriber can get our latest updates and download our 100+ scripts.