PxPlus User Forum

Twitter Twitter Twitter

Author Topic: Record Expansion Factor  (Read 764 times)

Alain Stucki

  • Member
  • **
  • Posts: 12
    • View Profile
Record Expansion Factor
« on: September 26, 2022, 11:45:07 AM »
Hello

Could someone please explain to me what Record Expansion factor is? See for example the attached screenshot. It's a variable length record of 400. I see a 10% record expansion factor. What does it mean and how can I use this? Furthermore I see that the record size range is indicated 400-2024. Now I'm completely confused... Can someone please enlighten me?

The reason I'm asking is that I have not enough space in this file. I would like to write records with a length of 430 characters instead of 400. So now I'm not sure if I can use 440 anyway without errors (those 10%) or as much as 2024. Or do I have to change the Max record size?

Of course I have checked the documentation but there is no explanation.

Thanks a lot in advance for your help and explanations.


Mike King

  • Diamond Member
  • *****
  • Posts: 3810
  • Mike King
    • View Profile
    • BBSysco Consulting
Re: Record Expansion Factor
« Reply #1 on: September 26, 2022, 01:45:45 PM »
The record expansion factor is basically how much space on each block of the data file is reserved for record expansion.

Generally PxPlus use Variable length record files  (VLR format).  These are stored in logical blocks within the data file where each block can contain multiple records and the records 'physical ' address consists of the block address and record number within the block. 

Because of this as the contents change so too does the space required to store the record change.  When a record is updated and its size shrinks, that space is returned to the block.  When a record grows if the block has enough free space the record remains in the same spot meaning the key tables (which contain the key values and associated record address) does not change.  However if the record grows to the point that there is not enough space in the block to contain the record, the record is physically move to a new block and the key tables updated with the new record address. 

The expansion factor controls how much free space to leave in each block to allow for record expansion.  When a block has less that the factor percentage of free space available new records will not be added to it and the block will be considered full.

Now in real life most blocks will always have some free space as it is unlikely that the records will fit exactly, however if your system is tight on disc space you can reduce this factor.

As for the record size, when using VLR files the maximum record your application can write is governed by the record size specified on the file; however you can increase this up to the block size without having to reload/rebuild the file.  When you increase the record size all the system does is change the file header and on subsequent file opens a larger buffer for holding the record is allocated.

You mentioned that the system advised you the record size could be changed to anything in the range of 400 to 2024 bytes.  Changing this will increase the buffer size allocated to the records, so if you increase this from 400 to say 500, the only impact on you system will be whenever the file is opened a 500 byte buffer will be allocated and not a 400 byte buffer.  Just be sure to have everyone exit the system when you make the change as anyone with the file currently open will only have a 400 byte buffer which would cause a problem it they encounter a record you have just added with the larger size.

It should also be noted that older BB applications often used Fixed length records (FLR format).  That meant that each record was a fixed size padded with nulls.  You may want to check to see if some of your larger files are using fixed length records as these are quite wasteful of disk space.   Generally you can convert these to variable length record files without impacting any of your programs other than those that might attempt to create the file as it would need to create a VLR file instead.

Mike King
President - BBSysco Consulting
eMail: mike.king@bbsysco.com

Alain Stucki

  • Member
  • **
  • Posts: 12
    • View Profile
Re: Record Expansion Factor
« Reply #2 on: September 26, 2022, 03:00:22 PM »
Hello Mr. King

Thanks for your fast and percise explanations.

As this is a VLR file I will use the GUI admin utility "Adjust Maximum Number of Records" when nobody is using PxPlus to set the max record size to a higher value and hope that your utility does all the necessary magic automatically  :)


Mike King

  • Diamond Member
  • *****
  • Posts: 3810
  • Mike King
    • View Profile
    • BBSysco Consulting
Re: Record Expansion Factor
« Reply #3 on: September 26, 2022, 04:09:03 PM »
Actually there is not a lot of magic involved.  All the utility does is reset the maximum record size for the file in the file header. 

That value is used to determine the program buffer size where the record is generated form the fields specified.
Mike King
President - BBSysco Consulting
eMail: mike.king@bbsysco.com