Re: rows selectivity overestimate for @> operator for arrays

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: rows selectivity overestimate for @> operator for arrays
Дата
Msg-id 2694646.1653674531@sss.pgh.pa.us
обсуждение исходный текст
Ответ на rows selectivity overestimate for @> operator for arrays  (Alexey Ermakov <alexey.ermakov@dataegret.com>)
Список pgsql-performance
Alexey Ermakov <alexey.ermakov@dataegret.com> writes:
> so if we store mostly one element in array and they're almost all 
> distinct then in tables with more then stats_target/0.0063 (~1.58M for 
> maximum stats target 10000) rows we'll get 0.005 constant for selectivity.

Yeah.  There's a comment in array_selfuncs.c about

 * TODO: this estimate probably could be improved by using the distinct
 * elements count histogram.  For example, excepting the special case of
 * "column @> '{}'", we can multiply the calculated selectivity by the
 * fraction of nonempty arrays in the column.

but I'm not sure whether that's relevant here.

One thought is that if there is a pg_statistic row but it contains
no MCE list, we could assume that the column elements are all distinct
and see what sort of estimate that leads us to.

            regards, tom lane



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

Предыдущее
От: Justin Pryzby
Дата:
Сообщение: Re: How to monitor Postgres real memory usage
Следующее
От: "James Pang (chaolpan)"
Дата:
Сообщение: postgres backend process hang on " D " state