Re: forcing use of a specific (expression) index? - Mailing list pgsql-general

From Tom Lane
Subject Re: forcing use of a specific (expression) index?
Date
Msg-id 21595.1178141896@sss.pgh.pa.us
Whole thread Raw
In response to forcing use of a specific (expression) index?  ("Dan Weber" <weberdan@gmail.com>)
List pgsql-general
"Dan Weber" <weberdan@gmail.com> writes:
> I have the following query:

> SELECT columns FROM my_table WHERE (bool_1 or int_1 = 0)
> AND (int_2 IS NULL) AND (int_3 IS NULL) AND (protocol =
> 2) ORDER BY id LIMIT 1;

> 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)));

A partial index would be WAY more useful than that:

create index on my_table(id) where (bool_1 or int_1 = 0) ...

            regards, tom lane

pgsql-general by date:

Previous
From: "Dan Weber"
Date:
Subject: forcing use of a specific (expression) index?
Next
From: Tom Lane
Date:
Subject: Re: Have I b0rked something? Slow comparisons on "where x in (...)"