A method and apparatus for merging synopses to determine a database
statistic, e.g., a number of distinct values (NDV), is disclosed. The
merging can be used to determine an initial database statistic or to
perform incremental statistics maintenance. For example, each synopsis
can pertain to a different partition, such that merging the synopses
generates a global statistic. When performing incremental maintenance,
only those synopses whose partitions have changed need to be updated.
Each synopsis contains domain values that summarize the statistic.
However, the synopses may initially contain domain values that are not
compatible with each other. Prior to merging the synopses the domain
values in each synopsis is made compatible with the domain values in the
other synopses. The adjustment is made such that each synopsis represents
the same range of domain values, in one embodiment. After "compatible
synopses" are formed, the synopses are merged by taking the union of the
compatible synopses.