Re: BUG #18442: Unnecessary Sort operator in indexScan Plan

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: BUG #18442: Unnecessary Sort operator in indexScan Plan
Дата
Msg-id 2135177.1713535423@sss.pgh.pa.us
обсуждение исходный текст
Ответ на BUG #18442: Unnecessary Sort operator in indexScan Plan  (PG Bug reporting form <noreply@postgresql.org>)
Ответы Re: BUG #18442: Unnecessary Sort operator in indexScan Plan  (David Rowley <dgrowleyml@gmail.com>)
Список pgsql-bugs
PG Bug reporting form <noreply@postgresql.org> writes:
> create index on t(a,b);
> postgres=# explain select * from t where a is null order by b; -- need
> sort
>                                    QUERY PLAN
> --------------------------------------------------------------------------------
>  Sort  (cost=9.54..9.80 rows=103 width=8)
>    Sort Key: b
>    ->  Index Only Scan using t_a_b_idx on t  (cost=0.29..6.10 rows=103
> width=8)
>          Index Cond: (a IS NULL)
> (4 rows)

Postgres doesn't detect that it could do this because "a IS NULL"
is not an equivalence condition.  You're not the first to suggest
that it could be treated as one, but I believe there are semantic
difficulties that would ensue.  One example is that given
"a IS NULL" and "a = b", the EquivalenceClass machinery would
think it can discard "a = b" and instead emit "b IS NULL",
which would not give the same answers.

            regards, tom lane



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

Предыдущее
От: Peter Petrov
Дата:
Сообщение: Re: BUG #18351: VACUUM FULL fails with error: missing chunk number 0 for toast value XXX
Следующее
От: PG Bug reporting form
Дата:
Сообщение: BUG #18443: jsonb_agg issue. Again.