You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
Collect and use element-frequency statistics for arrays.
This patch improves selectivity estimation for the array <@, &&, and @>(containment and overlaps) operators. It enables collection of statisticsabout individual array element values by ANALYZE, and introducesoperator-specific estimators that use these stats. In addition,ScalarArrayOpExpr constructs of the forms "const = ANY/ALL (array_column)"and "const <> ANY/ALL (array_column)" are estimated by treating them asvariants of the containment operators.Since we still collect scalar-style stats about the array values as awhole, the pg_stats view is expanded to show both these stats and thearray-style stats in separate columns. This creates an incompatible changein how stats for tsvector columns are displayed in pg_stats: the statsabout lexemes are now displayed in the array-related columns instead of theoriginal scalar-related columns.There are a few loose ends here, notably that it'd be nice to be able tosuppress either the scalar-style stats or the array-element stats forcolumns for which they're not useful. But the patch is in good enoughshape to commit for wider testing.Alexander Korotkov, reviewed by Noah Misch and Nathan Boley