"Phoenix Kiula" <phoenix.kiula@gmail.com> writes:
> A couple of questions about the "most_common_vals" stuff in pg_stats
> for a high traffic table:
> 1. Can I tell the stats collector to collect only values of a column
> where a certain regex is matched?
Not directly, but you could set up a partial index defined that way,
and ANALYZE would collect stats on the index contents. Whether the
planner could actually do anything with the information is another
story; I suspect you're wasting your time with this idea.
> 2. Secondly, for a unique column in the table, will the
> "most_common_vals" always be -1? I guess this could make sense, but I
> was wondering if the stats collector could somehow collect at least
> 1000 unique values to improve at least some performance.
most_common_vals will (and should) be empty if there aren't actually any
common values, but aren't you getting a histogram? Exactly what
performance do you think will be improved?
regards, tom lane