Your indexes are appropriate and your conclusions are correct.The questions:
Your indexes are appropriate for these queries and your conclusions are correct.
About partitions, they are rarely useful for performance. I don't think there is any point in using them in your case.
Minor remarks:
The
DESC
doesn't mean anything in that place. You can (try to) define a composite index with 4 ways:(FromUser ASC, DateCreated ASC) (FromUser ASC, DateCreated DESC) (FromUser DESC, DateCreated ASC) (FromUser DESC, DateCreated DESC)
but MySQL does not supoort DESC
indexes and will silently ignore these ASC
and DESC
. The index created will be the (ASC, ASC)
one.
Nothing to worry though as the indexes can and will be used for the queries you have. Indexes can be read fowards or backwards. The index would not be very efficient if you had (for example) a query with:
ORDER BY FromUser ASC, DateCreated DESC
where an (ASC, DESC)
index would be better.