1
0
mirror of https://github.com/postgres/postgres.git synced 2025-10-24 01:29:19 +03:00

Take pg_attribute out of VacAttrStats

The VacAttrStats structure contained the whole Form_pg_attribute for a
column, but it actually only needs attstattarget from there.  So
remove the Form_pg_attribute field and make a separate field for
attstattarget.  This simplifies some code for extended statistics that
doesn't deal with a column but an expression, which had to fake up
pg_attribute rows to satisfy internal APIs.  Also, we can remove some
comments that essentially said "don't look at pg_attribute directly".

Reviewed-by: Tomas Vondra <tomas.vondra@enterprisedb.com>
Discussion: https://www.postgresql.org/message-id/flat/d6069765-5971-04d3-c10d-e4f7b2e9c459%40eisentraut.org
This commit is contained in:
Peter Eisentraut
2023-07-03 07:09:22 +02:00
parent 7a7f60aef8
commit c69bdf837f
6 changed files with 43 additions and 80 deletions

View File

@@ -58,16 +58,14 @@ Datum
ts_typanalyze(PG_FUNCTION_ARGS)
{
VacAttrStats *stats = (VacAttrStats *) PG_GETARG_POINTER(0);
Form_pg_attribute attr = stats->attr;
/* If the attstattarget column is negative, use the default value */
/* NB: it is okay to scribble on stats->attr since it's a copy */
if (attr->attstattarget < 0)
attr->attstattarget = default_statistics_target;
if (stats->attstattarget < 0)
stats->attstattarget = default_statistics_target;
stats->compute_stats = compute_tsvector_stats;
/* see comment about the choice of minrows in commands/analyze.c */
stats->minrows = 300 * attr->attstattarget;
stats->minrows = 300 * stats->attstattarget;
PG_RETURN_BOOL(true);
}
@@ -169,7 +167,7 @@ compute_tsvector_stats(VacAttrStats *stats,
* the number of individual lexeme values tracked in pg_statistic ought to
* be more than the number of values for a simple scalar column.
*/
num_mcelem = stats->attr->attstattarget * 10;
num_mcelem = stats->attstattarget * 10;
/*
* We set bucket width equal to (num_mcelem + 10) / 0.007 as per the