Re: Ignoring index on (A is null), (A is not null) conditions

Поиск
Список
Период
Сортировка
От Cestmir Hybl
Тема Re: Ignoring index on (A is null), (A is not null) conditions
Дата
Msg-id 022001c39ed9$bfb09b20$0200a8c0@stratos
обсуждение исходный текст
Ответ на Ignoring index on (A is null), (A is not null) conditions  ("Cestmir Hybl" <cestmirl@freeside.sk>)
Ответы Re: Ignoring index on (A is null), (A is not null)  (Franco Bruno Borghesi <franco@akyasociados.com.ar>)
Re: Ignoring index on (A is null), (A is not null) conditions  (Bruno Wolff III <bruno@wolff.to>)
Re: Ignoring index on (A is null), (A is not null) conditions  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-performance
Are you seeing this question as totally off-topic in this list, or there is
really no one who knows something about indexing "is null" bits in postgres?

Regards
CH


> Hi,
>
> suppose, for simplicity, there is a table with index like this:
>
> create table TABLE1 (
>   A integer
> );
> create index TABLE1_A on TABLE1 (A);
>
> My question is: why psql (7.3.3) does not use index when filtering by A IS
> NULL, A IS NOT
> NULL expressions?
>
> In fact, I need to filter by expression ((A is null) or (A > const)).
>
> Is there a way to filter by this expression using index?
>
> Functional index cannot be used (except strange solution with CASE-ing and
> converting NULL values into some integer constant)
>
>
>
> --------------------------------------------------------------------------
--
> --
>  Index Scan using table1_a on table1  (cost=0.00..437.14 rows=29164
width=4)
>    Index Cond: (a > 1000)
> --------------------------------------------------------------------------
--
> --
>  Seq Scan on table1  (cost=0.00..448.22 rows=1 width=4)
>    Filter: (a IS NULL)
> --------------------------------------------------------
>  Seq Scan on table1  (cost=0.00..448.22 rows=30222 width=4)
>    Filter: (a IS NOT NULL)
> ------------------------------------------------------------
>  Seq Scan on table1  (cost=0.00..523.77 rows=29164 width=4)
>    Filter: ((a IS NULL) OR (a > 1000))
> ------------------------------------------------------------
>
>
> CH


В списке pgsql-performance по дате отправления:

Предыдущее
От: Rajesh Kumar Mallah
Дата:
Сообщение: Re: Query puts 7.3.4 on endless loop but 7.4beta5 is fine. [ with better indenting ]
Следующее
От: Christopher Browne
Дата:
Сообщение: Re: Query puts 7.3.4 on endless loop but 7.4beta5 is fine. [ with better indenting ]