Some very thick books have been written on this subject!
Here are some thumb ruins: -
Do not put indexing (except PK) on any table with <1000 rows.
Otherwise, index all of your FKs.
Examine your SQL and find where clauses that will most reduce your result sets and index this columun.
eg. Given:
SELECT OWNER FROM CARS WHERE COLOR = 'RED' AND MANUFACTURER = "BMW" AND ECAP = "2.0";
You can have 5,000 red cars out of 20,000, so indexing this will not help. However, you can only have 100 BMWs, so indexing MANUFACURER will immediately reduce your score to 100, and you can eliminate blue and white cars just by looking at a hundred lines.
Typically, dbms selects one or two of the available indices based on power, so it pays for a second guess and determines only those indices that are likely to be used.
source share