pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Joshua D. Drake <jd@commandprompt.com>
To: Chris Hoover <revoohc@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Alvaro Herrera <alvherre@commandprompt.com>
Cc: pgsql-admin@postgresql.org Admin <pgsql-admin@postgresql.org>
Subject: Re: 8.2.4 Won't Build 8.1 Functional Indexes
Date: Wed, 06 Jun 2007 21:35:39 -0700
Message-ID: <46678B1B.4050303@commandprompt.com> (raw)
In-Reply-To: <1d219a6f0706061916k73deaa6bv2dd9e800e77a6f24@mail.gmail.com>
References: <1d219a6f0706061112p355fc6cexb30a6b4b4bf187c3@mail.gmail.com>
	<20070606195459.GH11800@alvh.no-ip.org>
	<17138.1181173286@sss.pgh.pa.us>
	<1d219a6f0706061916k73deaa6bv2dd9e800e77a6f24@mail.gmail.com>

Chris Hoover wrote:
> Well, the one index:
> CREATE INDEX acceptedbilling_to_date

> The second index is rather stupid, it was an early index before I 
> figured out how to split a timestamp.
> 
> Anyway, is there a way to make the first index work?  Otherwise we end 
> up with a seq scan on our billing table which is very painful.

First, please do not top post:

http://www.catb.org/jargon/html/T/top-post.html

Second:

create function mydate(varchar) returns varchar AS $$ select 
to_char($1::date,'YYYYMMDD'); $$ LANGUAGE SQL IMMUTABLE;

create index foobar on date_test(mydate(date));

You will need to test this, but it does allow you to create the index.

Sincerely,

Joshua D. Drake


> 
> Thanks,
> 
> Chris
> 
> 
> On 6/6/07, *Tom Lane* <tgl@sss.pgh.pa.us <mailto:tgl@sss.pgh.pa.us>> wrote:
> 
>     Alvaro Herrera <alvherre@commandprompt.com
>     <mailto:alvherre@commandprompt.com>> writes:
>      > You can't do this because to_date and other functions are not
>     immutable.
>      > 8.2 seems to be more picky about this -- the date conversions of
>      > timestamptz columns are dependent on the current timezone.
> 
>     The reason 8.2 is more picky is that the function is less immutable
>     thanks to the addition of locale-dependent functionality:
>     http://archives.postgresql.org/pgsql-committers/2006-11/msg00264.php
> 
>     I gather that the underlying column is timestamp without tz, or it would
>     never have worked in 8.1 either.  That being the case, these index
>     definitions seem pretty darn stupid anyway --- why aren't you just
>     indexing on date_trunc or a plain cast to date?
> 
>                             regards, tom lane
> 
> 


-- 

       === The PostgreSQL Company: Command Prompt, Inc. ===
Sales/Support: +1.503.667.4564 || 24x7/Emergency: +1.800.492.2240
Providing the most comprehensive  PostgreSQL solutions since 1997
              http://www.commandprompt.com/

Donate to the PostgreSQL Project: http://www.postgresql.org/about/donate
PostgreSQL Replication: http://www.commandprompt.com/products/




view thread (6+ messages)

Message-ID: <46678B1B.4050303@commandprompt.com>
Permalink:  ../46678B1B.4050303@commandprompt.com/
Also on:    postgresql.org/message-id/46678B1B.4050303@commandprompt.com

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: jd@commandprompt.com, revoohc@gmail.com, tgl@sss.pgh.pa.us, alvherre@commandprompt.com
  Subject: Re: 8.2.4 Won't Build 8.1 Functional Indexes
  In-Reply-To: <46678B1B.4050303@commandprompt.com>

* 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