1

I have a table with 10000 records . Each data have a time of creation. I can use PHP time() function or as Mysql Timestamp (DATETIME '0000-00-00 00:00:00'). I want to know which method increase the performance of select queries? For example

Select * FROM MYDB WHERE datefield>1343821692 ORDER BY datefield DESC

or

Select * FROM MYDB WHERE datefield>'2012-08-01 13:41:1' ORDER BY datefield DESC

Please note that question bases on differences of INT sorting instead of DATETIME order. Also differences on restrictions.

Huseyin
  • 1,499
  • 2
  • 25
  • 39
  • possible duplicate of [datetime vs timestamp?](http://stackoverflow.com/questions/409286/datetime-vs-timestamp) – superEb Sep 01 '13 at 19:10
  • It is similar but not duplicated. Here I am interesting for performance WHEN I AM USING DATES AS "ORDER BY" AND RESTRICTION. – Huseyin Sep 01 '13 at 19:17

1 Answers1

1

I want to know which method increase the performance of select queries?

If one setup was bound to disk usage, one would expect INT to perform better, since storage requirements are smaller. However, the amount of calculations to use it as a timestamp can be overwhelming as well.

Check this out.

As far as there usage is concerned you can refer this Thread which will guide you when to use unix_time and when to use the other

Community
  • 1
  • 1
Rahul Tripathi
  • 168,305
  • 31
  • 280
  • 331
  • Sorting INT is faster than sorting DATETIME or reverse? – Huseyin Sep 01 '13 at 19:21
  • @Huseyin:- Yes you are right. Int is comparatively faster. I have updated my answer with a link which shows the difference. Hope it helps!!! And sorry for the previous answer :) – Rahul Tripathi Sep 01 '13 at 19:30