Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 3E8BD9FB28C for ; Wed, 7 Mar 2007 05:07:10 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-new, port 10024) with ESMTP id 88702-10 for ; Wed, 7 Mar 2007 05:07:06 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from mail.metronet.co.uk (mail.metronet.co.uk [213.162.97.75]) by postgresql.org (Postfix) with ESMTP id DC8C39FA2EF for ; Wed, 7 Mar 2007 05:07:06 -0400 (AST) Received: from server3.office.archonet.com (84-51-143-99.archon037.adsl.metronet.co.uk [84.51.143.99]) by smtp.metronet.co.uk (MetroNet Mail) with ESMTP id 0E1FB1433F2; Wed, 7 Mar 2007 09:05:35 +0000 (GMT) Received: from [192.168.1.36] (dell36.office.archonet.com [192.168.1.36]) by server3.office.archonet.com (Postfix) with ESMTP id B5E28274067; Wed, 7 Mar 2007 09:05:35 +0000 (GMT) Message-ID: <45EE805F.1060708@archonet.com> Date: Wed, 07 Mar 2007 09:05:35 +0000 From: Richard Huxton User-Agent: IceDove 1.5.0.9 (X11/20061220) MIME-Version: 1.0 To: Zoolin Lin Cc: pgsql-performance@postgresql.org Subject: Re: Any advantage to integer vs stored date w. timestamp References: <20070306214927.30058.qmail@web63311.mail.re1.yahoo.com> In-Reply-To: <20070306214927.30058.qmail@web63311.mail.re1.yahoo.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.209 tagged_above=0 required=5 tests=AWL, BAYES_50, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200703/149 X-Sequence-Number: 23554 Zoolin Lin wrote: > Hi, > > I have database with a huge amount of data so i'm trying to make it > as fast as possible and minimize space. > > One thing i've done is join on a prepopulated date lookup table to > prevent a bunch of rows with duplicate date columns. Without this I'd > have about 2500 rows per hour with the exact same date w. timestamp > in them. > > My question is, with postgres do I really gain anything by this, or > should I just use the date w. timestamp column on the primary table > and ditch the join on the date_id table. > > Primary table is all integers like: > > date id | num1 | num2 | num3 | num4 | num5 | num6 | num7 | num 8 > ------------------------------------------------------------------------------------------------- > primary key is on date to num->6 columns What types are num1->8? > date_id lookup table: > > This table is prepopulated with the date values that will be used. > > date_id | date w timestamp ---------------------------------------- 1 > | 2007-2-15 Midnight 2 | 2007-2-15 1 am 3 | 2007-2-15 > 2 am etc for 24 hours each day If you only want things accurate to an hour, you could lost the join and just store it as an int: 2007021500, 2007021501 etc. That should see you good to year 2100 or so. -- Richard Huxton Archonet Ltd