index a7a06146a06cfd007d77aa4658e2a4e0c080e339..23e5526a8e1453a8e1c47459061b2b602e913f8c 100644 (file)
@@ -5009,6 +5009,17 @@ get_variable_numdistinct(VariableStatData *vardata, bool *isdefault)
*/
stadistinct = 2.0;
}
+ else if (vardata->rel && vardata->rel->rtekind == RTE_VALUES)
+ {
+ /*
+ * If the Var represents a column of a VALUES RTE, assume it's unique.
+ * This could of course be very wrong, but it should tend to be true
+ * in well-written queries. We could consider examining the VALUES'
+ * contents to get some real statistics; but that only works if the
+ * entries are all constants, and it would be pretty expensive anyway.
+ */
+ stadistinct = -1.0; /* unique (and all non null) */
+ }
else
{
/*
index be2028867a85d01f4b07ab0fe03362e14c6c56a0..3ccc9d1b037cdb35dbab64beb652f6a362959405 100644 (file)
*
* relid - RTE index (this is redundant with the relids field, but
* is provided for convenience of access)
- * rtekind - distinguishes plain relation, subquery, or function RTE
+ * rtekind - copy of RTE's rtekind field
* min_attr, max_attr - range of valid AttrNumbers for rel
* attr_needed - array of bitmapsets indicating the highest joinrel
* in which each attribute is needed; if bit 0 is set then
/* information about a base rel (not set for join rels!) */
Index relid;
Oid reltablespace; /* containing tablespace */
- RTEKind rtekind; /* RELATION, SUBQUERY, or FUNCTION */
+ RTEKind rtekind; /* RELATION, SUBQUERY, FUNCTION, etc */
AttrNumber min_attr; /* smallest attrno of rel (often <0) */
AttrNumber max_attr; /* largest attrno of rel */
Relids *attr_needed; /* array indexed [min_attr .. max_attr] */