In this section, I will share the five most popular tips and we will review a real case of a company that is facing a performance problem with a query in MySQL.
Tips and techniques
The five general rules for your indexes
The five general rules to know when it is appropriate to create an index would be to respond positively to the following questions:
- Can you Index each primary key?
- Can you Index each foreign or secondary key?
- Can you Index each column used in a JOIN clause?
- Can you Index each column used in a WHERE?
- Can you Index each column used in a GROUP BY clause?
- Can you Index each column used in an ORDER BY clause?
- Are you going to generate reports?
In other words, indexes become necessary when you plan to use joins...