missing optimization - column <> column

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: missing optimization - column <> column
Date: 2016-12-05 15:18:19
Message-ID: CAFj8pRD-q59wQ-0WvJXik_U-R4LYN9_Caw9yJqAT-vHX0SMwnQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi

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

Regards

Pavel

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2016-12-05 15:21:18 Re: [COMMITTERS] pgsql: Introduce dynamic shared memory areas.
Previous Message Tom Lane 2016-12-05 15:17:04 Re: [COMMITTERS] pgsql: Introduce dynamic shared memory areas.