Skip to content

sql/stats: addOuterBuckets logic breaks CREATE STATISTICS USING EXTREMES #93094

@michae2

Description

@michae2

During (full) statistics collection we sometimes use addOuterBuckets to add buckets above and below the observed max and min values to account for extra distinct count:

// addOuterBuckets adds buckets above and below the existing buckets in the
// histogram to include the remaining distinct values in remDistinctCount. It
// also increments the counters rowCountEq, distinctCountEq, rowCountRange, and
// distinctCountRange as needed.
func (h *histogram) addOuterBuckets(

Unfortunately these buckets mislead the new USING EXTREMES partial statistics collection into only collecting stats above and below the max and min values for the column type.

I was hoping to delete addOuterBuckets when #83730 is fixed, so this might be fixed by that as well.

Jira issue: CRDB-22155

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-sql-table-statsTable statistics (and their automatic refresh).C-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.T-sql-queriesSQL Queries Team

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions