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

From: Zhihong Yu <zyu(at)yugabyte(dot)com>
To: Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Mark Dilger <mark(dot)dilger(at)enterprisedb(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 14:06:13
Message-ID: CALNJ-vQf_gydVipOP8Xxk5mzWda5LXDaLtdysygmJdbySBdNSg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, Aug 28, 2021 at 6:53 AM Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com>
wrote:

> Hi,
>
> The attached patch series is modified to improve estimates for these
> special clauses (Var op Var with the same var on both sides) without
> extended statistics. This is done in 0001, and it seems fairly simple
> and cheap.
>
> The 0002 part is still the same patch as on 2021/07/20. Part 0003 fixes
> handling of those clauses so that we don't treat them as simple, but it
> does that by tweaking statext_is_compatible_clause(), as suggested by
> Dean. It does work, although it's a bit more invasive than simply
> checking the shape of clause in statext_mcv_clauselist_selectivity.
>
> I do have results for the randomly generated queries, and this does
> improve the situation a lot - pretty much all the queries with (a=a) or
> (a<a) clauses had terrible estimates, and this fixes that.
>
> That being said, I'm still not sure if this is an issue in real-world
> applications, or whether we're solving something because of synthetic
> queries generated by the randomized generator. But the checks seem
> fairly cheap, so maybe it doesn't matter too much.
>
>
> regards
>
> --
> Tomas Vondra
> EnterpriseDB: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
Hi,
For 0001-Improve-estimates-for-Var-op-Var-with-the-s-20210828.patch :

+ * form (variable op variable) with the save variable on both sides.

typo: save -> same

Cheers

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2021-08-28 14:28:50 Re: Can we get rid of repeated queries from pg_dump?
Previous Message Tomas Vondra 2021-08-28 13:52:50 Re: Use extended statistics to estimate (Var op Var) clauses