Re: Use extended statistics to estimate (Var op Var) clauses

From: Mark Dilger <mark(dot)dilger(at)enterprisedb(dot)com>
To: Zhihong Yu <zyu(at)yugabyte(dot)com>
Cc: Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Use extended statistics to estimate (Var op Var) clauses
Date: 2021-08-28 17:40:08
Message-ID: E2517511-7474-4E8B-88C4-12CCB2BC0591@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> On Aug 28, 2021, at 10:18 AM, Zhihong Yu <zyu(at)yugabyte(dot)com> wrote:
>
> I wonder if the queries with (a=a) or (a<a) clauses are worth this additional complexity to address.
> Has anyone seen such clause in production queries ?

You might expect clauses like WHERE FALSE to be unusual, but that phrase gets added quite a lot by query generators. Somebody could add "WHERE a != a" in a misguided attempt to achieve the same thing.

I wouldn't be terribly surprised if query generators might generate queries with a variable number of tables joined together with comparisons between the joined tables, and in the degenerate case of only one table end up with a table column compared against itself.

You could argue that those people need to fix their queries/generators to not do this sort of thing, but the end user affected by such queries may have little ability to fix it.


Mark Dilger
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Justin Pryzby 2021-08-28 18:16:18 extended stats objects are the only thing written like "%s"."%s"
Previous Message Zhihong Yu 2021-08-28 17:18:06 Re: Use extended statistics to estimate (Var op Var) clauses