Re: missing optimization - column <> column

Поиск
Список
Период
Сортировка
Искать
От
Stephen Frost
Тема
Re: missing optimization - column <> column
Дата
Msg-id
20161205152352.GB23417@tamriel.snowman.net
Ответ на
Список
Дерево обсуждения
missing optimization - column <> column Pavel Stehule <pavel.stehule@gmail.com>
Re: missing optimization - column <> column Stephen Frost <sfrost@snowman.net>
Re: missing optimization - column <> column Pavel Stehule <pavel.stehule@gmail.com>
Re: missing optimization - column <> column Stephen Frost <sfrost@snowman.net>
Re: missing optimization - column <> column Pavel Stehule <pavel.stehule@gmail.com>
Re: missing optimization - column <> column Tom Lane <tgl@sss.pgh.pa.us>
Re: missing optimization - column <> column Pantelis Theodosiou <ypercube@gmail.com>
Re: missing optimization - column <> column Corey Huinker <corey.huinker@gmail.com>
Re: missing optimization - column <> column Pantelis Theodosiou <ypercube@gmail.com>
Re: missing optimization - column <> column Pavel Stehule <pavel.stehule@gmail.com>
Re: missing optimization - column <> column Serge Rielau <serge@rielau.com>
Pavel,

* Pavel Stehule (pavel.stehule@gmail.com) wrote:
> 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.

a <> a could go to NULL.  Obviously, that'll be false for such a simple
case, but it might not work out that way in a more complicated WHERE
clause.

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

a = a can't be replaced unless you know that 'a' can't be NULL.

In short, fix the application.

Thanks!

Stephen
В списке pgsql-hackers по дате отправления
От: Tom Lane
Дата:
От: Pavel Stehule
Дата:
FAQ