I have the following table ( file_category_tbl) for representing the connections between files and categories.
fileId - bigint(20)
categoryId - bigint(20)
order - int(10)
So that the files in the category can be sorted, I have an order field ... Therefore, my question is what indexes I will need for optimal performance according to the following:
SELECT * FROM file_category_tbl WHERE categoryId="3" ORDER BY order ASC
I have a unique index a UNIQUE ( fileId, categoryId); Because it cannot be the same fileIdwith the same categoryId. I also have an index on categoryId, since this is what is being executed. I also have an index on order? ... but is this necessary? since it only performs orderByon this ...
Respectfully to any defendant ... J
source
share