Re: How to hint 2 coulms IS NOT DISTINCT FROM each other

From: Kim Rose Carlsen <krc(at)hiper(dot)dk>
To: Merlin Moncure <mmoncure(at)gmail(dot)com>, Alban Hertroys <haramrae(at)gmail(dot)com>
Cc: Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: How to hint 2 coulms IS NOT DISTINCT FROM each other
Date: 2016-11-10 18:40:30
Message-ID: AM4PR0501MB26101ED977B399430B12F92FC7B80@AM4PR0501MB2610.eurprd05.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


> Hang on -- upthread the context was inner join, and the gripe was join

> fast with '=', slow with INDF. When he said the nulls were
> 'generated', I didn't follow that they were part of the original
> query. If the nulls are generated along with the query, sure, an
> index won't help.
>
> I maintain my earlier point; with respect to the original query, to
> get from performance of INDF to =, you have three options:
> a) expr index the nulls (assuming they are physically stored)
> b) convert to ((a = b) or a is null and b is null) which can help with
> a bitmap or plan
> c) covert to union all equivalent of "b"
>
> merlin

a) and b) would be workaround that would run an order of magnitude slower. The query
starts with a full table scan of a large table. If the planner had started elsewhere it could
have reduced the result to 1-2 rows from the start. It won't choose this plan without the help
from =.

c) could be a acceptable workaround, but it would clutter up if you would want more
than one column to be IS NOT DISTINCT FROM. You end up with 2^n unions to simulate
IS NOT DISTINCT FROM.

Without knowing the work required, I will still argue that having IS NOT DISTINCT FROM
use the same transitive rules as equality, would be a better approach.

With fear of talking about things I know little(nothing) of, I think the description of EquivalenceClasses
in postgres/src/backend/optimizer/README, should be extended to also include EquivalenceClasses
of IS NOT DISTINCT FROM.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jeff Janes 2016-11-10 20:20:36 Re: Gin indexes on intarray is fast when value in array does not exists, and slow, when value exists
Previous Message Tom Lane 2016-11-10 15:11:12 Re: Gin indexes on intarray is fast when value in array does not exists, and slow, when value exists