X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id E6EC5D1C4D5 for ; Wed, 30 Jul 2003 15:02:34 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 63280-09 for ; Wed, 30 Jul 2003 12:01:31 -0300 (ADT) Received: from pns.mm.eutelsat.org (pns.mm.eutelsat.org [194.214.173.227]) by svr1.postgresql.org (Postfix) with ESMTP id 13213D1C4D7 for ; Wed, 30 Jul 2003 12:02:32 -0300 (ADT) Received: from nts-03.mm.eutelsat.org (localhost [127.0.0.1]) by pns.mm.eutelsat.org (8.11.6/linuxconf) with ESMTP id h6UF5OR32101; Wed, 30 Jul 2003 17:05:24 +0200 Received: from gmendola (gmendola.mm.eutelsat.org [194.214.173.50]) by nts-03.mm.eutelsat.org (8.11.6/linuxconf) with SMTP id h6UEwVR17680; Wed, 30 Jul 2003 16:58:31 +0200 Message-ID: <002401c356ab$6007b4e0$32add6c2@mm.eutelsat.org> From: "Mendola Gaetano" To: Cc: "Dani Oderbolz" References: <3F25BC0B.3050000@ragingnet.com> <3F265EC3.5010603@ecologic.de> <20030729124246.GA15298@ontko.com> <3F267F15.9060705@ecologic.de> <00b701c3562c$a9aa83e0$10d4a8c0@mm.eutelsat.org> <3F279736.6010500@ecologic.de> Subject: Re: Partition DB Tables by month Date: Wed, 30 Jul 2003 17:00:54 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200307/330 X-Sequence-Number: 9670 "Dani Oderbolz" wrote: > Mendola Gaetano wrote: > > >you can easilly accomplish this using a partial index. > > > > > Would that really work with a view? > Can you post a syntax example for this? CREATE TABLE foo ( field_a field_b ...... fast_search BOOLEAN NOT NULL DEFAULT 1, time_stamp TIMESTAMPTZ NOT NULL DEFAULT now() ); CREATE INDEX idx_fast_search ON foo ( fast_search ) where fast_search = 't'; for each field to index: CREATE INDEX idx_field_a ON foo ( field_a ) where fast_search = 't'; CREATE INDEX idx_field_b ON foo ( field_b ) where fast_search = 't'; at the beginning of each month you can now do: UPDATE foo SET fast_search = 'f' WHERE time_stamp < now() AND fast_search = 't'; Your improved query for the last month: SELECT * FROM foo WHERE fast_search = 't' AND = XXXXX AND = YYYYYY; I hope this help Regards Gaetano