Re: rows selectivity overestimate for @> operator for arrays - Mailing list pgsql-performance

From Tom Lane
Subject Re: rows selectivity overestimate for @> operator for arrays
Date
Msg-id 2694646.1653674531@sss.pgh.pa.us
Whole thread Raw
In response to rows selectivity overestimate for @> operator for arrays  (Alexey Ermakov <alexey.ermakov@dataegret.com>)
List 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 by date:

Previous
From: Justin Pryzby
Date:
Subject: Re: How to monitor Postgres real memory usage
Next
From: "James Pang (chaolpan)"
Date:
Subject: postgres backend process hang on " D " state