Search Postgresql Archives

Re: Week numbers and calculating weekly statistics/diagrams

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Feb 16, 2010 at 01:14:26PM +0100, Alexander Farber wrote:
> Does anybody has an advice how to save the week number?
> 
> If I save it as a timestamp then calculating realtime statistics
> (on a player profile click) will probably be CPU-intensive,
> because I have to calculate the week numbers each time.

You should probably seperate the storage from the representation. The
easiest way of storing the information of a week is the date of the
first day (after all, a week could begin on a sunday or monday,
depending on your point of view). This will make grouping and searching
quick, as it's just an integer. 

If you really wanted to you could choose an epoch and count weeks from
there but I doubt that's worth the effort.

As for how you represent it to the users, you'll have to create some
conversion routine for output, but I seriously doubt that's going to be
a bottleneck.

Have a nice day,
-- 
Martijn van Oosterhout   <kleptog@xxxxxxxxx>   http://svana.org/kleptog/
> Please line up in a tree and maintain the heap invariant while 
> boarding. Thank you for flying nlogn airlines.

Attachment: signature.asc
Description: Digital signature


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux