If I have a table with columns: item_id, user_id, vote, date what columns should I put the index on considering:
-
I’ll need to fetch votes by date for time ranges and
-
there cannot be more than one vote for each item by a user.
Should the index be sorted ASC or DESC if I want to fetch dates that are more recent?
PRIMARY:item_id,user_id
INDEX: date
Sort DESC for latest first
Note: I assume you are storing date as UNIX TIMESTAMP (From your question title Timestamp Indexing)