i always had this question and i hope you can help me with this, how should i index created_at if i need to order results based on date.
Example:
COMMENTS TABLE:
- ID (UUID)
- ENTRY_ID (UUID)
- USER_ID (UUID)
- CONTENT
- FEATURED
- STATUS
- CREATED_AT
I have this indexes:
- PRIMARY: ID
- INDEX: ENTRY_ID
- INDEX: ENTRY_ID | CREATED_AT (to get latest entry comments)
- INDEX: USER_ID
- INDEX: USER_ID | CREATED_AT (to get latest user comments)
- INDEX: STATUS | CREATED_AT (to get comments marked as spam ordered by older first)
- INDEX: CREATED_AT (to get latest comments in entire db)
Is it right or i can skip some indexes?
ENTRY_IDand byUSER_IDare excess. – Akina Jan 22 '20 at 10:12