Performs various statistical calculations on the file keys.
This function is equivalent to HAccelerateSpeed.
These statistics are used when implementing a filter, creating a query or 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 iterations on data files.
The statistics are used to get information about the content of the data file when they are calculated. Therefore, the more modifications are performed in the file after this calculation, the less these statistics represent the true content of the data file. The more records the data file contains, the less the modification of a single record impacts the overall statistics.
prevents from writing to the data file during the calculation of statistics (an iteration is performed for each key in the data file).
The statistics can be calculated in background task without locking the data file in write mode.
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).
// Statistics on the CustName key of the Customer data file
<Result> = <Source>.StatCalculate([<Key item> [, <Option>]])
- True if the calculation was performed,
- False if a problem occurred (data file locked by an application for example). HError is used to identify the error.
<Source>: Type corresponding to the specified source
Name of the data file used.
Caution: This data file must not be locked by an application.
<Key item>: Optional character string
Name of the key item used to calculate statistics. If this name is not specified or if it is equal to "*", the statistics will be calculated for all key items found in the data file.
<Option>: Integer constant
Option for calculating the statistics.
Important: This parameter is taken into account for the HFSQL Client/Server files. In the other cases, the data file is automatically locked while the statistics are calculated.
- If this parameter is not specified, the calculation of statistics locks the data file in write mode.
- If this parameter corresponds to the hBackgroundTask constant, the statistics are calculated in background task, without locking the data file.
- <Source>.StatCalculate does not close the data file.
- The statistics can also be updated by <Source>.Index. <Source>.Index and <Source>.StatCalculate can both be used to update the file statistics.
- In the HFSQL Classic or Client/Server data files, the statistical calculation can only be performed on the key items.
- The syntax <Source>.StatCalculate(<Data file>) is equivalent to <Source>.StatCalculate(<Data file>, "*")
- To use <Source>.StatCalculate with the data files of an HFSQL cluster, the <Option> parameter must correspond to the hBackgroundTask constant to avoid locking the cluster.