tags:

views:

1044

answers:

1

I'm writing a php/mysql application which is similar to website visitors tracking solutions. It will handle 100,000s of inserts a day and will be able to be queried by counting pageviews/day etc...

I wonder if from terms of performance its better to keep time as integer (unix time) or as mysql time. Any idea on effect on performance? Seems like reteriving the data is easier with mysql time since I can use mysql function like DAYOFYEAR() without FROM_UNIXTIME(). Any advice is most welcomed.

+1  A: 

A TIMESTAMP will take slightly less storage space (4 bytes) than a DATETIME field. Performance-wise they should be roughly the same.

If you're thinking about doing GROUP BY DAYOFYEAR(...) then you might be better storing the DAYOFYEAR value in its own column to get better performance.

Greg
A datetime takes 8 bytes, while timestamp takes 4. that's 4 bytes of difference (see http://dev.mysql.com/doc/refman/5.1/en/storage-requirements.html)
tehvan
I knew I should have looked it up :|
Greg