S
S
skvot2012-09-26 11:21:29
MySQL
skvot, 2012-09-26 11:21:29

Unixtime vs datetime - query speed?

Hey habr!
I have a habit of storing all data in unixtime, I wondered if there were any pitfalls related to the speed of querying with unixtime, that is, are there any advantages in terms of speed in storing dates in datetime?
Interested in DBMS mysql and mssql.
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

3 answer(s)
R
rbtaxi, 2012-09-26
@rbtaxi

Store in a timestamp ) there will be no problems with time zones (just set the request to the desired time zone and voila).
Previously, he always stored time in int, then switched to timestamp. Visually more convenient + queries like date LIKE '2012-09-09%' rule and run quickly.

E
ertaquo, 2012-09-26
@ertaquo

As far as I know, Unixtime is better in terms of speed (after all, it's just a number), and in terms of functionality - DateTime (support for time zones and human-readable queries).

V
Vampiro, 2012-09-26
@Vampiro

In the muscle, timestamp, although it allows you to store ms, does not generate them on its own. Therefore, the nix format with a dot contains a more precise number. And yet, if with numeric values ​​the entire load for building a query is given to the client part, then with dateTime there is a temptation to shift it to the database (dateadd, diff, now, etc), and the database is more difficult to scale. It turns out a big load on the weak link. And yes, it’s more convenient to twist with dates.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question