Kbase P8154: How to calculate the size of a single character component in
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  02/02/2003 |
|
Status: Unverified
GOAL:
How to calculate the size of a single character component index?
FIX:
The disk space of an index is estimated by:
Number of Rows * ( 6 + Number of fields in the index + Index field storage) * 2)
For example if you have an index on a character field with an average of 21 characters for field index storage and 500 records then the index size is estimated to be:
500 * (6 + 1 + 21) * 2 = 29000 bytes.
The following code calculates the total number of records in the customer table, the average index field storage of the single component name index, and the total size of that index:
DEFINE VARIABLE dTotalFieldStorage AS DECIMAL NO-UNDO.
DEFINE VARIABLE iNumberOfRecords AS INTEGER NO-UNDO.
DEFINE VARIABLE iAverageFieldStorage AS INTEGER NO-UNDO.
DEFINE VARIABLE iTotalIndexStorageSize AS INTEGER NO-UNDO.
FOR EACH customer NO-LOCK:
ASSIGN
iNumberOfRecords = iNumberOfRecords + 1
dTotalFieldStorage = dTotalFieldStorage + LENGTH(NAME).
END.
ASSIGN
iAverageFieldStorage = dTotalFieldStorage / iNumberOfRecords.
IF iAverageFieldStorage > 240 THEN
iAverageFieldStorage = iAverageFieldStorage + 3.
ELSE
iAverageFieldStorage = iAverageFieldStorage + 1.
ASSIGN
iTotalIndexStorageSize = iNumberOfRecords * ( 6 + 1 + iAverageFieldStorage ) * 2.
MESSAGE
"Total Number Of Records:" "~t" iNumberOfRecords "Records" "~n"
"Average Field Storage: " "~t" iAverageFieldStorage " Bytes" "~n"
"Total Index Storage Size" "~t" iTotalIndexStorageSize " Bytes"
VIEW-AS ALERT-BOX INFO BUTTONS OK.