Re: forcing use of a specific (expression) index?

From: "Dan Weber" <weberdan(at)gmail(dot)com>
To: "Richard Huxton" <dev(at)archonet(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: forcing use of a specific (expression) index?
Date: 2007-05-03 13:39:40
Message-ID: 5dfa06e10705030639p7071133fy26288635606100cd@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Thanks to you and Tom. The partial index solution is working splendidly.

On 5/3/07, Richard Huxton <dev(at)archonet(dot)com> wrote:
> Dan Weber wrote:
> > I made an expression index specifically for that where clause:
> >
> > CREATE INDEX special_testing_idx on my_table (((bool_1 or
> > int_1 = 0) AND (int_2 IS NULL) AND (int_3 IS
> > NULL) AND (protocol = 2)));
>
> No, you haven't. What you've done here is create an index *for that
> expression*. And it's not terribly useful because your expression will
> only have two possible values: true, false.
>
> What you were after is something like:
>
> CREATE INDEX special_idx2 ON my_table (id) WHERE (...long expression...)
>
> --
> Richard Huxton
> Archonet Ltd
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Stephen Harris 2007-05-03 13:57:12 Re: Have I b0rked something? Slow comparisons on "where x in (...)"
Previous Message Andrei Kovalevski 2007-05-03 13:32:23 Re: C functions under windows