Tips to write an efficient and fast Mysql Query

Abhigyan Singh 09th Sep 2020

Note: I am updating this tutorial frequently when I see any new tips to speed up the 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 a 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. The primary key is very essential for MySQL operation.

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

(5) Always use LIMIT in the 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 a column name instead of writing any function like RAND, COUNT. It will slow our MYSQL query .

Authored By Abhigyan Singh

He is a continuous blogger and has blogged on different topic. He loves to surf Internet and always trying to get new Idea about new Technology and Innovations and sharing these great information to all the technology lovers.

Also on DiscussDesk