Re: Improve rowcount estimate for UNNEST(column)

Поиск
Список
Период
Сортировка
От jian he
Тема Re: Improve rowcount estimate for UNNEST(column)
Дата
Msg-id CACJufxEax35yb0eVfdHQ-xus6YVK-rEDjTXj1BdbBe3-mmtcFA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Improve rowcount estimate for UNNEST(column)  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Improve rowcount estimate for UNNEST(column)  (jian he <jian.universality@gmail.com>)
Список pgsql-hackers
Hi.
Since both array_op_test, arrest both are not dropped at the end of
src/test/regress/sql/arrays.sql.
I found using table array_op_test test more convincing.

select
        reltuples * 10 as original,
        reltuples * (select
floor(elem_count_histogram[array_length(elem_count_histogram,1)])
        from    pg_stats
        where   tablename = 'array_op_test' and         attname = 'i')
as with_patch
        ,(select (elem_count_histogram[array_length(elem_count_histogram,1)])
        from    pg_stats
        where   tablename = 'array_op_test' and         attname = 'i')
as elem_count_histogram_last_element
from pg_class where relname = 'array_op_test';
 original | with_patch | elem_count_histogram_last_element
----------+------------+-----------------------------------
     1030 |        412 |                         4.7843137
(1 row)

without patch:
explain select unnest(i)  from array_op_test;
                              QUERY PLAN
----------------------------------------------------------------------
 ProjectSet  (cost=0.00..9.95 rows=1030 width=4)
   ->  Seq Scan on array_op_test  (cost=0.00..4.03 rows=103 width=40)
(2 rows)

with patch:
 explain select unnest(i)  from array_op_test;
                              QUERY PLAN
----------------------------------------------------------------------
 ProjectSet  (cost=0.00..6.86 rows=412 width=4)
   ->  Seq Scan on array_op_test  (cost=0.00..4.03 rows=103 width=40)
(2 rows)
--------
because, in the estimate_array_length function, `nelem =
sslot.numbers[sslot.nnumbers - 1];` will round  4.7843137 to 4.
so with patch estimated row 412 = 103 *4. without patch estimated rows
= 103 * 10.



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

Предыдущее
От: "Fujii.Yuki@df.MitsubishiElectric.co.jp"
Дата:
Сообщение: RE: Partial aggregates pushdown
Следующее
От: Peter Eisentraut
Дата:
Сообщение: Re: Catalog domain not-null constraints