views:

25

answers:

2

Hi,

since in mysql datetime field is represented as string (i'm not sure how it works internally), wouldn't be from performance point of view faster to store date as unix timestamp? I don't need to use any mysql native date functions, i'm going for performance of sorting and selecting data.

if there was an index for that column, would be difference between int and datetime?

Thank you

A: 

You can use the TIMESTAMP data type, which is stored internally as an int: http://dev.mysql.com/doc/refman/5.1/en/datetime.html

Ike Walker
+1  A: 

Timestamp needs 4 bytes while datetime needs 8 bytes per record. It means smaller indexes and better performance but not in each case:

How much faster is timestamp than datetime column in MySQL?

Piotr Pankowski