Today at 11:01am, Sasha Pachev said:

>If you are a storing timestamps, you should use MySQL timestamp type, and
>definitely not a varchar, as it would just waste space. Timestamps are
>stored as efficiently as they could possibly be - a 4-byte integer,

I don't mean to nit pick too much, but while that may be the most
efficient way "in general", for timestamps measured in seconds covering a
span of about 68 years. But IIRC, something was mentioned about them
simply being times, all within a single day. if that's the case, there's
only 86,400 seconds to worry about, rather than a few billion, which can
be stored in 17 bits instead of 32. Mysql's time type (as opposed to
timestamp or datetime) might be a better fit in this particular case. If
only minutes are needed, rather than seconds, then you've only got 1440
values, and can do it in 11 bits, or 2-byte int, or a 4-byte char[], or
whatever.

On a side note, space isn't the only consideration when deciding what
format to use. If you're storing it in a format that you'll have to
convert most of the time before you can use it, then you're trading the
space you save for the computation time it costs to do the conversions. On
a busy web server, for instance, that may not be the way you want to make
the tradeoff. Granted, in this case, the difference might look pretty
small, but if you multiply it by thousands or millions of times you'll
have to convert it, the time savings may be more important than the space
savings.

Mac

--
Mac Newbold             MNE - Mac Newbold Enterprises, LLC
[EMAIL PROTECTED]       http://www.macnewbold.com/

____________________
BYU Unix Users Group 
http://uug.byu.edu/ 
___________________________________________________________________
List Info: http://uug.byu.edu/cgi-bin/mailman/listinfo/uug-list

Reply via email to