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 91431D1B55A for ; Fri, 3 Oct 2003 21:03:52 +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 43017-04 for ; Fri, 3 Oct 2003 18:03:04 -0300 (ADT) Received: from wight.ymogen.net (unknown [217.27.240.153]) by svr1.postgresql.org (Postfix) with SMTP id 914B7D1B54B for ; Fri, 3 Oct 2003 18:02:03 -0300 (ADT) Received: (qmail 29117 invoked from network); 3 Oct 2003 21:01:54 -0000 Received: from dsl-217-155-239-51.zen.co.uk (HELO finisterre) (217.155.239.51) by wight.ymogen.net with SMTP; 3 Oct 2003 21:01:54 -0000 From: "Matt Clark" To: "Jeff Boes" , Subject: Re: Partial indexes ... any good theoretical discussion? Date: Fri, 3 Oct 2003 22:01:52 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0) In-Reply-To: X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Importance: Normal X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/51 X-Sequence-Number: 10612 It won't work. You could instead have a separate boolean attribute called 'expired' for each row. Set this to true whenever you expire the row, and create the partial index using that attr. Matt > -----Original Message----- > From: pgsql-admin-owner@postgresql.org > [mailto:pgsql-admin-owner@postgresql.org]On Behalf Of Jeff Boes > Sent: 03 October 2003 17:35 > To: pgsql-admin@postgresql.org > Subject: [ADMIN] Partial indexes ... any good theoretical discussion? > > > I've only just now noticed that CREATE INDEX accepts a 'WHERE' clause. > This is used to create something called a "partial index". Hmm, ever > being one who sees the world as made of nails when first given a > hammer ... > > One of our tables, with a couple hundred thousand rows) has a > date-column index. We expire things out of the table every day (the vast > majority, but not exclusively, stuff that's a couple days old). We're > frequently running queries against the table, looking for "everything > since this time yesterday"; we hardly ever look back more than 24 hours. > > If I created the index as something like: > > CREATE INDEX ix_foo ON foo(the_date) > WHERE the_date >= now() - interval '24 hours'; > > what might I expect as the impact? Do index values older than 24 hours > drop out? Or must I "refresh" the index from time to time (in our > application, probably a couple dozen times a day)? > > And, absent pat answers to this, is there anything out there in PG-land > that documents partial indexes, and when to use them? > > -- > Jeff Boes vox 269.226.9550 ext 24 > Database Engineer fax 269.349.9076 > Nexcerpt, Inc. http://www.nexcerpt.com > ...Nexcerpt... Extend your Expertise > > > ---------------------------(end of broadcast)--------------------------- > TIP 7: don't forget to increase your free space map settings >