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

From Scott Marlowe
Subject Re: How to hint 2 coulms IS NOT DISTINCT FROM each other
Date
Msg-id CAOR=d=3-jViQf_11heE9AHd=0uRd7aNcyVbKCbdsmUm44r6vhQ@mail.gmail.com
Whole thread Raw
In response to Re: How to hint 2 coulms IS NOT DISTINCT FROM each other  (Kim Rose Carlsen <krc@hiper.dk>)
Responses Re: How to hint 2 coulms IS NOT DISTINCT FROM each other  (Kim Rose Carlsen <krc@hiper.dk>)
List pgsql-general
On Sat, Oct 29, 2016 at 6:55 AM, Kim Rose Carlsen <krc@hiper.dk> wrote:
>> try this :-D
>
>> create or replace function indf(anyelement, anyelement) returns anyelement
>> as
>> $$
>>   select $1 = $2 or ($1 is null and $2 is null);
>> $$ language sql;
>>
>> CREATE VIEW view_circuit_with_status AS (
>>    SELECT r.*,
>>           s.circuit_status,
>>           s.customer_id AS s_customer_id,
>>           p.line_speed,
>>           p.customer_id AS p_customer_id
>>      FROM view_circuit r
>>      JOIN view_circuit_product_main s
>>        ON r.circuit_id = s.circuit_id
>>       AND indf(r.customer_id, s.customer_id)
>>      JOIN view_circuit_product p
>>        ON r.circuit_id = p.circuit_id
>>       AND indf(r.customer_id, s.customer_id)
>>
>> merlin
>
> This doesn't do much good. This doesn't tell the planner that the 3
> customer_ids are actually of same value, and it therefore can't filter them
> as it sees fit.

You do know you can index on a function, and the planner then keeps
stats on it when you run analyze right?


pgsql-general by date:

Previous
From: Kim Rose Carlsen
Date:
Subject: Re: How to hint 2 coulms IS NOT DISTINCT FROM each other
Next
From: Chris Mair
Date:
Subject: Re: Best way to return Random rows from a table with non-repeatability of rows