开发者

Are integer queries on MySQL DATE or TIME columns slow?

Is it more efficient for me to store dates as INTs and convert to and fro a string representation such as "2010-01-30" or is it alright to store dates as DATE when needing to perform very frequent integer queries such as WHERE Date < 20100130... Ar开发者_C百科e dates internally stored as strings or integers?


DATE is actually only a 3-byte column, as opposed to a normal INT column which is 4 bytes, so are actually smaller. When you do a query on a DATE field, when you're passing in an integer representation of the date (i.e where `date` < 20100210), it will be converted to the 3-byte value and compared that way... Then again, a DATE field will just store dates and no time information.

It's more efficient to store the date as a DATE.

For more info, look here: http://dev.mysql.com/doc/refman/5.0/en/storage-requirements.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜