Range cell and total density values

Adaptive Server stores two values for the density of column values:

Using two separate values improves the optimizer’s estimates of the number of rows to be returned:

For joins, the optimizer bases its estimates on the average number of rows to be returned for each scan of the table, so the total density, which measures the average number of duplicates for all values in the column, provides the best estimate. The total density is also used for equality arguments when the value of the search argument is not known when the query is optimized.

See “Range and in-between selectivity values” for more information.

For indexes on multiple columns, the range-cell density and total density are stored for each prefix subset. In the sample output below for an index on titles (pub_id, type, pubdate), the density values decrease with each additional column considered.

Statistics for column:              "pub_id"
Last update of column statistics:   Feb  4 1998 12:58PM

     Range cell density:            0.0335391029690461
     Total density:                 0.0335470400000000
 
Statistics for column group:        "pub_id", "type"
Last update of column statistics:   Feb  4 1998 12:58PM

     Range cell density:            0.0039044009265108
     Total density:                 0.0039048000000000

Statistics for column group:        "pub_id", "type", "pubdate"
Last update of column statistics:   Feb  4 1998 12:58PM

     Range cell density:            0.0002011791956201
     Total density:                 0.0002011200000000

With 5000 rows in the table, the increasing precision of the optimizer’s estimates of rows to be returned depends on the number of search arguments used in the query:

This increasing level of accuracy as more search arguments are evaluated can greatly improve the optimization of many queries.