Re: using extended statistics to improve join estimates

From: Andrei Lepikhov <a(dot)lepikhov(at)postgrespro(dot)ru>
To: Andy Fan <zhihuifan1213(at)163(dot)com>
Cc: Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com>, Julien Rouhaud <rjuju123(at)gmail(dot)com>, Andres Freund <andres(at)anarazel(dot)de>, pgsql-hackers(at)postgresql(dot)org, Justin Pryzby <pryzby(at)telsasoft(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: using extended statistics to improve join estimates
Date: 2024-05-23 03:22:09
Message-ID: 5c9a1eee-c8ac-408b-95c4-ff388e5e12f0@postgrespro.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 5/23/24 09:04, Andy Fan wrote:
> Andrei Lepikhov <a(dot)lepikhov(at)postgrespro(dot)ru> writes:
>> * c) No extended stats with MCV. If there are multiple join clauses,
>> * we can try using ndistinct coefficients and do what eqjoinsel does.
>
> OK, I didn't pay enough attention to this comment before. and yes, I get
> the same conclusion as you - there is no implementation of this.
>
> and if so, I think we should remove the comments and do the
> implementation in the next patch.
I have an opposite opinion about it:
1. distinct estimation is more universal thing - you can use it
precisely on any subset of columns.
2. distinct estimation is faster - it just a number, you don't need to
detoast huge array of values and compare them one-by-one.

So, IMO, it is essential part of join estimation and it should be
implemented like in eqjoinsel.
> Do you think the hook proposal is closely connected with the current
> topic? IIUC it's seems not. So a dedicated thread to explain the problem
> to slove and the proposal and the follwing discussion should be helpful
> for both topics. I'm just worried about mixing the two in one thread
> would make things complexer unnecessarily.
Sure.

--
regards,
Andrei Lepikhov
Postgres Professional

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David Rowley 2024-05-23 03:25:47 Re: Minor fixes for couple some comments around MERGE RETURNING
Previous Message David Rowley 2024-05-23 02:27:07 Re: First draft of PG 17 release notes