views:

298

answers:

1

I was just wondering which field type would be the best solution for storing a timestamp in a MySQL database.

Currently I store timestamps in an INT (10) field and insert the time by doing UNIX_TIMESTAMP(). If I was to use a timestamp field would it be slower or quicker when indexed? I know both fields use 4 bytes.

+1  A: 

They're both implemented by a 4 byte integer so the indexes should perform equally well.

Khorkrak
Thanks for confirming what I thought :)
Paul Janaway
You aren't limited to 1 timestamp column per table.But only one timestamp column can be updated automatically on insert or update (can be the same or different columns)
Naktibalda
You're right Naktibalda - just checked it myself. I had remembered it incorrectly so I've removed that from my answer.
Khorkrak