A question about mysql Index

Let"s say that there are three fields in the Table table, which are all high-frequency queries for Filter conditions. If you set up a composite index (An and B), some query combinations will cause the index to fail, so why not build an index on all three fields? What is the significance of the existence of composite indexes? What is the best indexing strategy for this situation?

Mar.14,2021

now that you've asked, and I quite agree with you, what is the purpose of composite indexes? What is the function of the index? Let's not do it all at all. With regard to your index establishment, depending on the situation, if your table is only a high-frequency query, and the modification operation is relatively few, then you can consider multi-index, that is, build a combined index and then build other indexes. I won't say much because I don't know your specific project needs.


if the query condition contains three fields of A/B/C, then the composite index using ABC is the most efficient.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b370e3-3442d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b370e3-3442d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?