Received: from localhost (maia-2.hub.org [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 776BC9FB2BE for ; Tue, 23 Jan 2007 09:24:44 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-new, port 10024) with ESMTP id 26282-08 for ; Tue, 23 Jan 2007 09:24:35 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from nf-out-0910.google.com (nf-out-0910.google.com [64.233.182.186]) by postgresql.org (Postfix) with ESMTP id 6E8C99FB28B for ; Tue, 23 Jan 2007 09:24:40 -0400 (AST) Received: by nf-out-0910.google.com with SMTP id x4so233999nfb for ; Tue, 23 Jan 2007 05:24:35 -0800 (PST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=plS08NcztL/R1IJgTmmVcrpk9BcbYy0+JgnnYCwNbnG0Ixj6lhgBaMCQCy2pv1nPTgN7zopq4FYNbv8EX1qcjLihUBirR8+7Z+PpqIzr8S7oWqlXwbgbczsTHjsRixn/WnsYTsRU+YKmXe0Rt+9lkUGqN5p7Lx50tBU2W54+CQ4= Received: by 10.49.92.18 with SMTP id u18mr1068428nfl.1169558674068; Tue, 23 Jan 2007 05:24:34 -0800 (PST) Received: by 10.49.65.8 with HTTP; Tue, 23 Jan 2007 05:24:34 -0800 (PST) Message-ID: <81961ff50701230524y14aa883alfe4dab8d1dd5cf10@mail.gmail.com> Date: Tue, 23 Jan 2007 08:24:34 -0500 From: "Chad Wagner" To: "Tobias Brox" Subject: Re: extract(field from timestamp) vs date dimension Cc: pgsql-performance@postgresql.org In-Reply-To: <20070123124937.GA13122@oppetid.no> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_3048_12748352.1169558674014" References: <20070123124937.GA13122@oppetid.no> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200701/347 X-Sequence-Number: 22948 ------=_Part_3048_12748352.1169558674014 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 1/23/07, Tobias Brox wrote: > > Ralph Kimball seems to be some kind of guru on data warehousing, and > in his books he's strongly recommending to have a date dimension - > simply a table describing all dates in the system, and having I would tend to agree with this line of thought. out from elsewhere - but as for now, I'm mostly only interessted in > grouping turnover/profit by weeks/months/quarters/years/weekdays. It > seems so much bloated to store this information, my gut feeling tells it > should be better to generate them on the fly. Postgres even allows to > create an index on an expression. I guess go with your gut, but at some point the expressions are going to be too complicated to maintain, and inefficient. Calendar tables are very very common, because traditional date functions simply can't define business logic (especially things like month end close, quarter end close, and year end close) that doesn't have any repeating patterns (every 4th friday, 1st monday in the quarter, etc). Sure you can stuff it into a function, but it just isn't as maintainable as a table. -- Chad http://www.postgresqlforums.com/ ------=_Part_3048_12748352.1169558674014 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline On 1/23/07, Tobias Brox <tobias@nordicbet.com> wrote:
Ralph Kimball seems to be some kind of guru on data warehousing, and
in his books he's strongly recommending to have a date dimension -
simply a table describing all dates in the system, and having

I would tend to agree with this line of thought.
 

out from elsewhere - but as for now, I'm mostly only interessted in
grouping turnover/profit by weeks/months/quarters/years/weekdays.  It
seems so much bloated to store this information, my gut feeling tells it
should be better to generate them on the fly.  Postgres even allows to
create an index on an expression.

I guess go with your gut, but at some point the expressions are going to be too complicated to maintain, and inefficient.

Calendar tables are very very common, because traditional date functions simply can't define business logic (especially things like month end close, quarter end close, and year end close) that doesn't have any repeating patterns (every 4th friday, 1st monday in the quarter, etc).  Sure you can stuff it into a function, but it just isn't as maintainable as a table.




--
Chad
http://www.postgresqlforums.com/ ------=_Part_3048_12748352.1169558674014--