Re: planner chooses incremental but not the best one

Поиск
Список
Период
Сортировка
От Tomas Vondra
Тема Re: planner chooses incremental but not the best one
Дата
Msg-id d29e8962-eef7-7045-6b49-470cc11b3bf5@enterprisedb.com
обсуждение исходный текст
Ответ на Re: planner chooses incremental but not the best one  (Richard Guo <guofenglinux@gmail.com>)
Ответы Re: planner chooses incremental but not the best one  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers

On 12/15/23 09:58, Richard Guo wrote:
> 
> On Thu, Dec 14, 2023 at 6:02 PM Richard Guo <guofenglinux@gmail.com
> <mailto:guofenglinux@gmail.com>> wrote:
> 
>     It seems that we need to improve estimate of distinct values in
>     estimate_num_groups() when taking the selectivity of restrictions into
>     account.
> 
>     In 84f9a35e3 we changed to a new formula to perform such estimation.
>     But that does not apply to the case here, because for an appendrel,
>     set_append_rel_size() always sets "raw tuples" count equal to "rows",
>     and that would make estimate_num_groups() skip the adjustment of the
>     estimate using the new formula.
> 
> 
> I'm wondering why we set the appendrel's 'tuples' equal to its 'rows'.
> Why don't we set it to the accumulated estimate of tuples from each live
> child, like attached?  I believe this aligns more closely with reality.
> 

Yeah, seems like that's the right thing to do. FWIW I've been often
confused by these fields, because we use tuples and rows as synonyms,
but in this particular case that's not the same. I wonder if this is
just a manifestation of this confusion.

> And this would also allow us to adjust the estimate for the number of
> distinct values in estimate_num_groups() for appendrels using the new
> formula introduced in 84f9a35e3.

I don't follow. Why wouldn't it be using the new formula even without
your patch? (using the "wrong" value, ofc, but the same formula).


regards

-- 
Tomas Vondra
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tomas Vondra
Дата:
Сообщение: Re: brininsert optimization opportunity
Следующее
От: Tom Lane
Дата:
Сообщение: Re: planner chooses incremental but not the best one