Patent ID: 7624094

Claim:
A computer-implemented method of managing data in a database, comprising: selecting, using a query optimizer, an executable procedure from a plurality of procedures that operate on data in the database, wherein said query optimizer automatically: generates a statistic derived from the data that is operated upon by one of the plurality of procedures; and determines an optimal execution procedure based on said statistics, wherein the statistics are calculated automatically when the statistics are needed to determine the optimal execution procedure via a process comprising: accumulating names of columns to be processed by the execution procedure lacking statistics; determining whether the columns are of a type for which statistics may be generated, such that: in an event a selected column is of the type for which statistics may be generated, and the statistic does not already exist, automatically generating the statistic; and in an event the selected column is not of the type for which statistics may be generated, not generating the statistics, wherein types of columns for which statistics may not be generated comprise: read-only; and graph; selects the optimal executable procedure from the plurality of procedures based on the statistics including generated statistics; determines a threshold number of query modifications for the columns referenced by the generated statistic; maintains a modification counter of query modifications to the data referenced by the generated statistic; and recalculates the generated statistic when the modification counter reaches the threshold.