Consultor Eletrônico



Kbase P19897: What does progress do when deleting records from the database?
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   20/01/2010
Status: Verified

GOAL:

Will deleting records free up space within the database?

GOAL:

Does Progress reuse space freed from record deletion?

FACT(s) (Environment):

All Supported Operating Systems
Progress/OpenEdge Versions

FIX:

Progress will reuse space that has been freed up by means of deletions, depending on how much space each deletion left.

There are three blocks in question:

1. The RM (Record Management) blocks which contain data. Blocks on the RM Chain blocks are neither full nor empty. If a block has at least the Create Limit (300 bytes by default in OpenEdge 10 or 250 bytes free (150 for systems with 512 byte blocks) in earlier versions), then the block is put on the RM Chain. When the RM Block is removed from the RM Chain, the database engine leaves the Toss Limit (150 bytes free by default in OpenEdge 10 or 75 bytes in earlier versions), in each block to allow for expansion in the event that the record is updated in the future. This is to reduce the number of records that are split across multiple blocks.

2. The Free Chain blocks are empty database formatted blocks below the Storage Area's High Water Mark. These blocks are available to be allocated as either index blocks or data blocks.

3. Empty blocks are completely empty and unformatted. They have never contained data, they are above the Storage Area's High Water Mark, made available for use when the space allocation algorithm requires.

Each block within Progress is equal to the size of the database blocksize.

The blocks on the RM Chain are there due to the creation of records leaving a block partially full, or the deletion of records leaving the block partially empty. Either way, this block can hold more data and is therefore left on the RM Chain. Once it is completely full (still allowing for expansion space) or completely empty it is popped to the RM blocks or the Free Chain respectively.

After many deletions, there are now many blocks on the RM Chain. When a new record is created, Progress will search the RM Chain for space to accomodate the new record.

To find space to store a record, or a record fragment, the database manager first looks at the RM chain to see if an existing record block with unused space is available. If the block at the head of the RM chain contains enough space to store the fragment while still leaving expansion space (Toss Limit), and the block has unused record slots, then that block is used. The record is copied to the block and the amount of unused space in the block is updated.

If the block at the head of the RM chain cannot be used to store the record, and it has less unused space than the Toss Limit, or if all 32 record slots have been used, it is removed off the RM chain. Otherwise it is moved to the tail end of the chain. In either case, the next block on the front of the RM chain is considered and the process is repeated until sufficient space has been found or the search limits have been reached.

The algorithm needs to balance the search with performance. To limit the search time, no more than 100 blocks on the RM chain will be examined and removed from the chain at a time. No more than 3 consecutive blocks at a time will be examined and moved to the tail end. If either of these limits are exceeded during a search for space, the search for reusable space is abandoned and a free block is used by moving it from the from the Free Chain the RM Chain.

If no existing record block can be used, an unused block is allocated from the Empty blocks. The Storage Area's High-Water Mark is rasied, the block is formatted as an RM block, and finally the record is stored in it. If the record is larger than 1 block, another block from the Free Chain is used to hold the overflow. The first block that we searched in the RM Chain is then moved to the bottom of the RM Chain so that the same blocks are not repeatedly searched.

To answer the question:

If the records are all greater than the size of 1 block of the database, then the space on the RM Chain cannot be re-used, since the remaining space is less than or equal to the size of 1 blo.ck. This will cause Progress to grab blocks from the Free Chain to load records which will cause the database to grow. When the number of Free Chain blocks becomes low, the database will extend to grab more blocks for the Empty Chain. Bear in mind, that a 10MB record deletion, does not equate to 10MB/databaseblocksize available blocks on the RM chain. The records may well have been fragmented in the first place.

The "proutil <dbname> -C dbanalys" and "prostrct statistics <dbname>" utilities are useful reports to get information about how well or poorly space is being utilized..