Re: missing optimization - column <> column

Поиск
Список
Период
Сортировка
От Pavel Stehule
Тема Re: missing optimization - column <> column
Дата
Msg-id CAFj8pRA3pun+SP1jr=Bj9E4t-sLqw7cEXK0vDXBEUFJphAqOjA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: missing optimization - column <> column  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: missing optimization - column <> column  (Serge Rielau <serge@rielau.com>)
Список pgsql-hackers


2016-12-05 16:24 GMT+01:00 Tom Lane <tgl@sss.pgh.pa.us>:
Pavel Stehule <pavel.stehule@gmail.com> writes:
> I found some crazy queries in one customer application. These queries are
> stupid, but it was surprise for me so there are not some simple optimization

> create table foo(a int);
> insert into foo select generate_series(1,100000);
> analyze foo;
> explain select * from foo where a <> a;

> It does full scan of foo, although it should be replaced by false in
> planner time.

> Same issue is a expression a = a .. can be replaced by true

Wrong; those expressions yield NULL for NULL input.  You could perhaps
optimize them slightly into some form of is-null test, but it hardly
seems worth the planner cycles to check for.

understand
 

If you write something like "1 <> 1", it will be folded.

it works, but a <> a not

Regards

Pavel

                        regards, tom lane

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

Предыдущее
От: Stephen Frost
Дата:
Сообщение: Re: missing optimization - column <> column
Следующее
От: Pavel Stehule
Дата:
Сообщение: Re: missing optimization - column <> column