Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
When answering the question "whether it makes sense to index field X" you should always operate:
0. Features of a particular DBMS.
1. Structure of tables.
2. The structure of the request.
3. The contents of the table.
4. EXPLAIN results on request before indexing.
5. EXPLAIN results after test indexing.
In your question, you did not cite any of the above, so you can only give theoretical calculations:
1. The cardinality of this index will be low. It's not very good, but it's not fatal either.
2. For inquiriesselect id from mytable where field = 1;
this index can give a decent profit, provided that the table has many other columns - the DBMS will not have to read extra data from the disk, only the index will be used. If the query is more complicated or the table is simpler, then the profit decreases. Specific values can only be given by EXPLAIN.
Learn to work with EXPLAIN, no answers on the Internet will help better than him. Another good book to read is High Performance MySQL .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question