Forum Moderators: coopster

Message Too Old, No Replies

Which is Faster In MySQL? Comparing Unix Times, or DATETIMES?

         

kazisdaman3

9:29 am on Dec 21, 2007 (gmt 0)

10+ Year Member



I'm leaning towards using unix times inserted into my MySQL for ease of use in manipulating the data with PHP. I think this will be the final decision, which one would be faster?

--

Mysql:
* INT (4 bytes)
* DATETIME (8 bytes)
* TIMESTAMP (4 bytes)

--

My PHP application does alot of querying from the database to compare specific data within TIMERANGES, so always, I'm querying with "time >" or "time <".

My question is would doing the WHERE time query with the native MySQL DATETIME be faster, than doing a WHERE query with the unix timestamp?

timster

5:19 pm on Dec 21, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you are concerned about performance at this level, there is no substitute for running your own performance tests.

In the past I've accepted authoritative-sounding answers on performance questions like this in the past, only to find out they simply weren't true for my application/OS/server version.

You can use PHP's microtime() function and a for loop.