Patent ID: 7519637

Claim:
A method for reorganizing at least a portion of a database, the portion of the database comprising one or more reference groups, each of which include a plurality of rows stored in a plurality of physical blocks, comprising: identifying a target subset of physical blocks for at least one of the reference groups, each block in the target subset having available freespace and storing a plurality of the rows in the at least one reference group; identifying a source subset of physical blocks for the at least one reference group, each block in the source subset storing at least one of the plurality of rows in the at least one reference group; and dynamically moving the rows in the at least one reference group stored in the source subset of physical blocks to the freespace in the target subset of physical blocks while the database is online, wherein dynamically moving the rows includes: sorting the identified target subset of physical blocks according to an amount of available freespace in each particular target physical block; sorting the identified source subset of physical blocks according to a number of rows in the reference group stored in each particular source physical block; and dynamically selecting the rows to be moved from the source subset of physical blocks to the target subset of physical blocks based on the sorting of the target and source subsets of physical blocks.