Re: missing optimization - column <> column

From: Corey Huinker <corey(dot)huinker(at)gmail(dot)com>
To: Pantelis Theodosiou <ypercube(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: missing optimization - column <> column
Date: 2016-12-05 19:02:22
Message-ID: CADkLM=ciBNo8Q2adv6VJBAX_2SHGd3pbggKaeFKnsM730mCZDw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

>
>
> Would it be worth replacing the condition with the equivalent?
> I mean would that help optimizing better some queries when it knows that a
> is (not) nullable or when "a" is more complicated expression?
>
> a <> a : (a IS NULL) AND NULL
> a = a : (a IS NOT NULL) OR NULL
>

I think you're looking for

a IS DISTINCT FROM a

And that will work for cases where a might be null.

I have no opinion about whether adding such a test to the planner is worth
it.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2016-12-05 19:06:29 Re: [COMMITTERS] pgsql: Introduce dynamic shared memory areas.
Previous Message Mithun Cy 2016-12-05 18:59:47 Re: Patch: Implement failover on libpq connect level.