views:

30

answers:

1

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... Are dates internally stored as strings or integers?

+1  A: 

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

Mike Sherov