I have table in which there is timestamp field (in format yyyy-MM-dd HH:mm:ss.SSS ) (timestamp without time zone) and a non-unique field (string format) .
Consider an example:
Assume this is table User(userId,userType,modifiedOn).
userType is non-unique key and modifiedOn is timestamp without time zone.
User Table is updating on some eligible criteria by other jobs at some 20 - 40 minutes interval.
userType can be max 200 distinct value while User table have millions of data.
What type of indexing should I use ?
Currently I am trying
CREATE INDEX user_modifiedOn_userType_index on user USING btree(modifiedOn,userType);
Note :
I am putting between this range of time like this modifiedOn between '04-APR-18 07:44:21' and '06-APR-18 07:44:21'.
Currently using postgresql version 9.6 later will shift to 10.3
But I have doubts:
1) How much order of columns matter in multiColumn indexing?
Thought: modifiedOn will have millions of distinct values so it should come first while userType have hardly 200 distinct values.
2) Is Indexing on timestamp possible upto hour or min? If it is possible then how much it will impact on performance.