How do I group different rows in a field?

What's more efficient when working with mySQL? Save a date in unix timestamp within an integer field or using unix_timestamp() function on a string field with a date formated like 'Sat May 12 22:52:01 +0000 2012'?  I will be using this field to count and group rows.

  • Answer:

    The integer, which is 4-bytes, blows the string away, which I counted to be 30 characters which usually ends up being approximately that many bytes. Also note that there is a TIMESTAMP column type in MySQL that is used for this very purpose: it stores unixtimes in 4 bytes and lets you use all sorts of nice date manipulation functions instead of manipulating the integers yourself. TIMESTAMP is the most efficient way to store a timestamp, that is until 4 byte unixtimes wrap around in 2038, at which time it will be Y2K all over again.

Jay Janssen at Quora Visit the source

Was this solution helpful to you?

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.