Entering indexes inside will partially help queries if it leads directly to the correct result, but it can also bring great benefits if it improves the locality of links and reduces the amount of data read.
In the question that is asked, the answer is "it depends." It depends on your requests. If you specify one main column that always appears in the search, for example. INT1
, create an index:
unique (INT1, INT2, INT3, REF)
Then any query that references INT1 and any combination of other fields will be fast.
In addition, any query that refers to INT2, but not to INt1, will also be useful, because the entire table does not need to be read - only the index. Despite the fact that INT2 is not at the head of the index, the query still wins: DB will skip INT1 and just look at INT2, but it can get a view of the values โโof the INT2 table without having to read the whole table.
So, you need to better understand the requests that will be executed. If one ALLWAYS column appears, put it at the beginning of the index. If another OFTEN column appears, it must be the number 2.
If there are two columns that appear frequently, you can do this:
unique (INT1, INT2, INT3, REF), unique (INT2, INT1, INT3, REF)
Then we hope that if INT1 is not specified, but INT2 is specified, the second index will be used.
Do not use too many indexes, although they can take up a lot of disk space.
Bottom line: Check queries with and without indexes. You need to collect 10-20 minimum sample requests and check their I / O time and hours. This is the only way to get a true answer.