Re: How to hint 2 coulms IS NOT DISTINCT FROM each other - Mailing list pgsql-general

From Alban Hertroys
Subject Re: How to hint 2 coulms IS NOT DISTINCT FROM each other
Date
Msg-id CAF-3MvN4pUd5bPKGRGVvQ5N4EzvxUjbp283wP1K5unOvprZ5hQ@mail.gmail.com
Whole thread Raw
In response to Re: How to hint 2 coulms IS NOT DISTINCT FROM each other  (Merlin Moncure <mmoncure@gmail.com>)
Responses Re: How to hint 2 coulms IS NOT DISTINCT FROM each other  (Merlin Moncure <mmoncure@gmail.com>)
List pgsql-general
On 4 November 2016 at 14:41, Merlin Moncure <mmoncure@gmail.com> wrote:
> On Fri, Nov 4, 2016 at 8:08 AM, Kim Rose Carlsen <krc@hiper.dk> wrote:
>> The nulls are generated by something like this
>>     SELECT c.circuit_id,
>>                    cc.customer_id
>>        FROM circuit AS c
>> LEFT JOIN circuit_customer AS cc
>>              ON c.circuit_id = cc.circuit_id
>>
>> To make a magic '0' customer we would be required to use
>>   COALESCE(cc.customer_id, '0')
>> I dont think the optimizer will do anything clever with the '0' we have
>> computed from null.
>
> It would if you explicitly indexed it as such;
> CREATE INDEX ON circuit_customer((COALESCE(customer_id, '0'));

Merlin, it's a LEFT JOIN. There probably are no NULLs in the
circuit_customer.customer_id column, so that COALESCE isn't going to
achieve anything at all.

I haven't been following this particular discussion in detail, so
unfortunately I can't contribute more than that remark at the moment.

--
If you can't see the forest for the trees,
Cut the trees and you'll see there is no forest.


pgsql-general by date:

Previous
From: "Hu, Patricia"
Date:
Subject: What is the best thing to do with PUBLIC schema in Postgresql database
Next
From: Adrian Klaver
Date:
Subject: Re: Recover from corrupted database due to failing disk