Reorganizes the internal structure of the indexes to optimize the speed for accessing the data. Based on HStatCalculate
, this function performs several statistical calculations on the keys of a data file.
When should HAccelerateSpeed be used?
This function can be used as often as necessary but we advise you to use it after a set of additions (in most cases, after a set of additions corresponding to at least 1 per thousand of the number of records in the database).
Remark: In order for the statistical calculation to be efficient, this calculation must be performed on all data files (for a multi-file query for example).
Caution: This function must not be systematically used in the initialization code of the project. Indeed, optimizing the speed for accessing the data may take quite a long time and the users may be slowed down.
How does HAccelerateSpeed work?
The statistics on the keys of a data file are used when implementing a filter, when creating a query or when creating a view on the data file. The HFSQL engine analyzes the selection condition, then uses these statistics to define the most discriminating items that will be used to optimize the browse operations on data files.
The statistics are used to get information about the content of the data file when they are calculated. Once the statistics have been calculated:
- The more the data file is modified, the less accurate the statistics are.
- The more records the data file contains, the less the modification of a single record impacts the overall statistics.
locks the data file in write mode when the statistics are calculated (a file browse is performed for each file key).
The statistics can be calculated in background task without locking the data file in write mode.
Remark: From version 19, HFSQL is the new name of HyperFileSQL.
// Reorganizes the Customer data file on the CustName key
<Result> = HAccelerateSpeed([<Data file> [, <Key item> [, <Optimization>]]])
- True if the reorganization of indexes was performed,
- False if a problem occurred (file locked by an application for example). HError is used to identify the error.
<Data file>: Optional character string (with or without quotes)
Name of data file used. If this name is not specified, HAccelerateSpeed will use the last data file used by the last HFSQL management function (function starting with "H").
If this parameter is equal to "*" (without specifying any item), the operation will be performed on all the data files described in the current analysis (including the data files described by HDeclare, HDeclareExternal, HDescribeFile).
Caution: This data file must not be locked by an application.
<Key item>: Optional character string (with or without quotes)
Name of the key item used to reorganize the indexes. If this name is not specified or if it is equal to "*", the reorganization of indexes will be performed on all the key items of the data file.
<Optimization>: Integer constant
Used to optimize the reorganization of indexes for the HFSQL Client/Server files.
If this parameter is not specified, the data file used will be locked in write mode.
If this parameter corresponds to the hBackgroundTask
constant, the reorganization of indexes will be performed in background task, without locking the data file. Important
: This parameter is taken into account for the HFSQL Client/Server files. In the other cases, the file is automatically locked when the statistics are calculated.
- HAccelerateSpeed does not close the data file.
- The reorganization of indexes can also be performed by HIndex or by HStatCalculate.
- In the HFSQL Classic or Client/Server data files, the reorganization of indexes can only be performed on the key items.
- The syntax HAccelerateSpeed(<Data file>) is equivalent to HAccelerateSpeed(<Data file>, "*")
Business / UI classification: Business Logic