1. A method of generating optimization data for a database management system, the method comprising: determining a density for each key value of a plurality of key values in a table over at least one range of rows in the database table; and storing the determined densities in a data structure for use in optimizing a query that references a key value in the plurality of key values in the table.