What is the best way to index a datetime in MySQL? Which method is faster:
- Store the datetime as a double (via unix timestamp)
- Store the datetime as a datetime
The application generating the timestamp data can output either format. Unfortunately, datetime will be a key for this particular data structure so speed will matter.
Also, is it possible to make an index on an expression? For example, index on UNIX_TIMESTAMP(mydate)
where mydate is a field in a table and UNIX_TIMESTAMP is a mysql function. I know that Postgres can do it. I'm thinking there must be a way in mysql as well.