pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Jeff Boes <jboes@nexcerpt.com>
Cc: pgsql-admin@postgresql.org
Subject: Re: Partial indexes ... any good theoretical discussion?
Date: Fri, 03 Oct 2003 13:17:17 -0400
Message-ID: <28177.1065201437@sss.pgh.pa.us> (raw)
In-Reply-To: <d701af91955b194af069c0b945f35c16@news.teranews.com>
References: <d701af91955b194af069c0b945f35c16@news.teranews.com>

Jeff Boes <jboes@nexcerpt.com> writes:
> 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?

You won't be allowed to, because now() isn't immutable, and only
immutable functions are allowed in index expressions and predicates.

You could imagine a batch job every night creating a new index

    CREATE INDEX ix_foo_20031003 ON foo(the_date)
      WHERE the_date >= '2003-10-03'

and then dropping the prior index.  Dunno if this would be worth the trouble,
but it might be.  The CREATE INDEX should run quite quickly if it only
has to pick up a few rows, which it would if you run it shortly after
the chosen boundary.

> And, absent pat answers to this, is there anything out there in PG-land 
> that documents partial indexes, and when to use them?

http://developer.postgresql.org/docs/postgres/indexes-partial.html
The links at the bottom of the page point to various academic
papers (I hope the links all still work...)

			regards, tom lane



view thread (4+ messages)  latest in thread

Message-ID: <28177.1065201437@sss.pgh.pa.us>
Permalink:  ../28177.1065201437@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/28177.1065201437@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: tgl@sss.pgh.pa.us, jboes@nexcerpt.com
  Subject: Re: Partial indexes ... any good theoretical discussion?
  In-Reply-To: <28177.1065201437@sss.pgh.pa.us>
  References: <d701af91955b194af069c0b945f35c16@news.teranews.com> <28177.1065201437@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox