Patent ID: 7720874

Claim:
A computer-implemented method for dynamically allocating space for a fixed length part of a variable length field in a database table, comprising the steps of: determining, by using a computer, whether statement calls for a table to be created or altered; if the statement calls for the table to be created or altered, determining whether a variable length field is included in the statement; and if a variable length field is included in the statement, for each variable length field included in the statement, performing steps of finding a matching historical record maintained by a database management system (DBMS), determining an estimated optimal fixed portion length based on the matching historical record, and setting a space allocation length for the fixed length part of the variable length field based on the estimated optimal fixed portion length, wherein the statement is a CREATE table statement or an ALTER table statement, wherein the variable length field is a variable character (VARCHAR) field, and wherein each record in the VARCHAR field includes a fixed length part, a variable length part, and a pointer to the variable length part, wherein the historical record maintained by the DBMS includes a count and a total length associated with the fixed length part of the VARCHAR field, wherein the historical record is initialized by performing the steps of: for each table to reset, getting the table; for each column in the table to reset, getting the column, setting the count in a historical record associated with the fixed length part of the column to zero, and setting the total length in the historical record associated with the fixed length part of the column to zero.