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

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: forcing use of a specific (expression) index?
Дата
Msg-id 21595.1178141896@sss.pgh.pa.us
обсуждение исходный текст
Ответ на forcing use of a specific (expression) index?  ("Dan Weber" <weberdan@gmail.com>)
Список 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 по дате отправления:

Предыдущее
От: "Dan Weber"
Дата:
Сообщение: forcing use of a specific (expression) index?
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Have I b0rked something? Slow comparisons on "where x in (...)"