I have a query that gets run often. its a dynmaic sql query because the sort by changes.
SELECT userID, ROW_NUMBER(OVER created) as rownumber
from users
where
divisionID = @divisionID and isenrolled=1
the OVER part of the query can be:
- userid
- created
Should I create an index for:
- divisionID + isenrolled
- divisionID + isenrolled + each_sort_by_option ?
Where should I put indexes for this table?