1
1
17aPaBo3uK2018-12-11 13:33:37
MySQL
17aPaBo3uK, 2018-12-11 13:33:37

Is it worth adding indexes to a table where there will be few records?

Hello everyone, tell me if it's worth adding indexes to a table where there will be few records?
There will be a maximum of 30 entries, so adding an index will be good or bad?
As I understand it, indexes are added to the table, where there are a lot of records, so that the sql query would run faster.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
longclaps, 2018-12-11
@longclaps

You can add or remove an external index at any time, for example now or later.
The harm will be from premature optimization, which you are currently concerned about.

P
ponaehal, 2018-12-11
@ponaehal

I believe that you need to add indexes, just like all kinds of keys and restrictions.
1. All this gives the optimizer a hint on the correct construction of the query plan.
2. Records in the table are not ordered on disk. If you need to read from disk (if the table is not in memory) in order to read the table, many reads may be needed. It's easier with an index.
3. Lack of indexes on a foreign key can lead to locks on insertion.
It is clear that there are a lot of BUTs (according to the situation), but if the cost of adding an entry to the index is not critical, then I am in favor of building indexes and collecting statistics ....

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question