Feasibility of using a highly volatile field as the lead of a compound index

Is this compound index feasible:

  last_logged_in: -1, // milliseconds
  age: -1,
  height: -1,
  gps: -1,
  education: -1,
  // etc., 20 more fields

The challenge is that this compound index contains more than 20 fields and the lead field, last_logged_in, will be highly volatile. It is constantly updated.

So the question is, will write queries be too slow?

Whenever a user logs in, last log in time will change and that means an index update (and with B+ tree, the index may also have to be moved around).

So it may not be a good idea if you have a lot of “active log in” users every day.

1 Like