ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / Managing databases / HFSQL / Managing statistics
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Collects statistics on data file keys.
This function is equivalent to HAccelerateSpeed.
These statistics are used when applying 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. Also, the more modifications there are to the data file after this calculation, the less accurately these statistics represent the contents of the data file. The more records the data file contains, the less the modification of a single record impacts the overall statistics.
Note: HStatCalculate prevents any write operations to the data file while statistics are being calculated (the data file is read for each key).
HFSQL Client/Server Statistics can be calculated in the background, without locking the data file.
New in SaaS
HFSQL Client/Server Statistics for an HFSQL Client/Server data file can be calculated asynchronously using HStatCalculateAsynchronous.
Note: This feature is only available from WINDEV Suite SaaS 2025 - Update 2.
For more details, see Using new features exclusive to WINDEV Suite SaaS 2025.
Note: For optimal results, this calculation must include all data files (e.g. multi-file query).
Example
// Statistics on the CustName key of the Customer data file
HStatCalculate(Customer, CustomerName)
Syntax
<Result> = HStatCalculate([<Data file> [, <Key item> [, <Option>]]])
<Result>: Boolean
  • 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.
<Data file>: Optional character string
Name of the data file used. If this name is not specified, HStatCalculate will use the last data file used by the last HFSQL function (function starting with "H").
If this parameter is equal to "*" (without specifying any item), the calculation will be performed on all 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
Name of the key item used to calculate statistics. If this name is not specified or is set to "*", statistics will be calculated for all key items in the data file.
<Option>: Integer constant
Option for calculating the statistics.
  • If this parameter is not specified, the calculation of statistics locks the data file.
  • If this parameter is set to the hBackgroundTask constant, statistics are calculated in the background, without locking the data file.
Important: This parameter is only taken into account for HFSQL Client/Server data files. In all other cases, the data file is automatically locked while statistics are being calculated.
Remarks
  • HStatCalculate does not close the data file.
  • Statistics can also be updated using HIndex. HIndex and HStatCalculate can both be used to update the file statistics.
  • In HFSQL Classic or Client/Server data files, only key items can be used to calculate statistics.
  • The syntax HStatCalculate(<Data file>) is equivalent to HStatCalculate(<Data file>, "*")
  • To use HStatCalculate with the data files of an HFSQL cluster, the <Option> parameter must correspond to the hBackgroundTask constant to avoid locking the cluster.
Component: wd300hf.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 06/24/2025

Send a report | Local help