• Sergei Petrunia's avatar
    MDEV-31067: selectivity_from_histogram >1.0 for a DOUBLE_PREC_HB histogram · 85cc8318
    Sergei Petrunia authored
    Variant #2.
    
    When Histogram::point_selectivity() sees that the point value of interest
    falls into one bucket, it tries to guess whether the bucket has many
    different (unpopular) values or a few popular values. (The number of
    rows is fixed, as it's a Height-balanced histogram).
    The basis for this guess is the "width" of the value range the bucket
    covers. Buckets covering wider value ranges are assumed to contain
    values with proportionally lower frequencies.
    
    This is just a [brave] guesswork. For a very narrow bucket, it may
    produce an estimate that's larger than total #rows in the bucket
    or even in the whole table.
    
    Remove the guesswork and replace it with basic logic: return
    either the per-table average selectivity of col=const, or selectivity
    of one bucket, whichever is lower.
    85cc8318
selectivity.result 98.7 KB