MySQL Integer vs DateTime index

后端 未结 3 381
小鲜肉
小鲜肉 2020-11-30 04:21

Let me start by saying I have looked at many similar questions asked, but all of them relate to Timestamp and DateTime field type without indexing.

相关标签:
3条回答
  • 2020-11-30 05:08

    it depends on your application, as you can see in an awesome comparison and benchmark of DATETIME , TIMESTAMP and INT type in Mysql server in MySQL Date Format: What Datatype Should You Use? We Compare Datetime, Timestamp and INT. you can see in some situation INT has better perfomance than other and in some cases DATETIME has better performance. and It completely depends on your application

    0 讨论(0)
  • 2020-11-30 05:12

    I see that in the test mentioned in the above answer, the author basically proves it that when the UNIX time is calculated in advance, INT wins.

    0 讨论(0)
  • 2020-11-30 05:18

    My instinct would be to say that ints are always faster. However, this seems not to be the case

    http://gpshumano.blogs.dri.pt/2009/07/06/mysql-datetime-vs-timestamp-vs-int-performance-and-benchmarking-with-myisam/

    Edited to add: I realize that you're using InnoDB, rather than MyISAM, but I haven't found anything to contradict this in the InnoDB case. Also, the same author did an InnoDB test

    http://gpshumano.blogs.dri.pt/2009/07/06/mysql-datetime-vs-timestamp-vs-int-performance-and-benchmarking-with-innodb/

    0 讨论(0)
提交回复
热议问题