ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

The content of this page has been updated to version 2025.  See "Using new features exclusive to a subscription-based version in a project".
Help / WLanguage / Managing databases / HFSQL / HFSQL functions
  • Use conditions
  • Automatic reindexing
  • "Zero-downtime" reindexing
  • Calculating statistics
  • Directory of temporary files
  • Managing non-Latin character sets
  • Access rights to the data file
  • Special case: Data files corrupted after a reboot or a fatal error
  • Previous versions
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Rebuilds the file index (".NDX" file). You can also reindex:
  • full-text indexes (".FTX" files),
  • spatial indexes (".SDX" files).
A data file can be reindexed even when it is accessed by one or more applications. For more details, see remarks.
Subscription-exclusive new feature
HFSQL Client/Server Client/Server HFSQL data files can be reindexed asynchronously using HReindexAsynchronous.
Note: This feature is only available in subscription-based versions, starting with WINDEV Suite 2025 - Update 2.
For more details, see Using new features exclusive to the subscription-based version of WINDEV Suite 2025.
Reminder: Reindexing reorganizes indexes and can free up space left when records are deleted. After reindexing, the access to indexes is optimized. Reindexing a data file can become necessary further to the loss or modification of the index file. HCheckIndex is used to regularly check the status of the index file.
IF HIndex(AFile, hNdxNormal) = True THEN
	TableDisplay(TABLE_MyTable, taStart)
END
Syntax
<Result> = HIndex([<Data file> [, <Mode> [, <Progress Bar> [, <Density rate>]]]])
<Result>: Boolean
  • True if the reindex operation was successfully performed,
  • False otherwise. HError returns more details about the problem.
<Data file>: Optional character string
Name of the data file used.
If this name is not specified, HIndex will use the last data file used by the last HFSQL function (function starting with "H").
<Mode>: Optional Integer constant (or combination of constants)
Reindexing configuration:
hChangeCharsetReindexing with change of character set.
The new character set defined by ChangeCharset will be taken into account during the reindexing. Sorts, searches or other types of operations performed on string keys (strings, characters, date and time) will use the new character set.
hFTXReindexing of full-text indexes.
hMmoCompactCompression and defragmentation of "Mmo" files.

Caution: This constant cannot be combined with the hNdxCompact, hCheckMemo, hFTX, hSDX, hNdxNormal or hNdxDelete constants.
hNdxCompactReindexing with compression: Only active records are preserved. All the other records are permanently deleted. The space left by the deleted records is deleted from the data file and the index (".FIC" and ".NDX" files, respectively).
Note: If one or more records are in a transaction, compression is automatically disabled.
hNdxMinimalReindexing while taking into account only corrupted keys. This parameter is ignored if the hNdxDelete or hNdxCompact constant are enabled.
hNdxSilentReindexing without display.
hNdxNormal
(default value)
Standard reindexing (with statistics and without compression).
Statistics help optimize queries and filters (see the Notes). Only active records are taken into account for calculating statistics.
hNdxNoStatReindexing without calculating statistics. This constant saves space by reducing the index file size.
Note: Statistics are important to achieve acceptable execution times when using queries, conditional filters and views with conditions.
hNdxDeleteReindex and delete damaged records.
hSDXReindexing of spatial indexes.
hBackgroundTask
HFSQL Client/Server Reindexing in the background. Applications are not locked during reindexing.
This feature is available in Client/Server mode only.
hCheckMemoStandard reindexing with verification of Memo items and correction if necessary (can be used to retrieve damaged memos).
WINDEVWEBDEV - Server code Note: You can regularly check the status of memos before reindexing them, using HCheckMemo.
<Progress Bar>: Optional control or window name, or optional integer
  • Name of the window in which the progress bar will be displayed,
  • Name of the Progress Bar control that displays the reindexing progress,
  • Handle of the window that displays the progress bar.
WEBDEV - Server code This parameter is ignored.
<Density rate>: Integer between 1 and 100
Density rate of indexes. This rate is set to 60 by default.
The higher this rate is, the denser and smaller the index is. In this case, iterations, searches, filters and queries will be faster. Adding and modifying records may take longer.
The smallest this rate is, the less dense and the bigger the index will be. In this case, iterations, searches, filters and queries will be slower. Adding and modifying records will be faster.
Caution: This parameter can only be used on HFSQL data files..
Hyper File 5.5 This parameter cannot be used.
Remarks

Use conditions

  • HIndex reindexes an xBase file.
  • HIndex is used to reindex data files in a cluster. In this case:
    • Reindexing is performed on the node to which the user is connected.
    • Only zero-downtime reindexing is available (hBackgroundTask constant).
WINDEVWEBDEV - Server codeReports and QueriesiPhone/iPadUser code (UMC)External languageAjaxHFSQL ClassicHFSQL Client/Server

Automatic reindexing

It may be necessary to reindex a data file if the index file has been lost or damaged. An automatic reindexing can be implemented for the data files.
To implement an automatic reindex operation, you must:
  • configure the value of the H.AutoIndexingLimit variable.
    Indeed, if the data file contains less than H.AutoIndexingLimit records, the reindex operation is automatically performed if an index error occurs.
    The H.AutoIndexingLimit variable is set to 10000 by default. The automatic reindex operation is disabled if this variable is set to 0.
  • configure the value of the H.VisibleAutoIndexing variable.
    If this value is set to True (default value), a window is automatically displayed as long as the automatic reindex operation is not completed. This window contains a progress bar used to track the progress of the current reindexing. This window can be customized. For more details, see HFSQL error handling help.
    Any applications that manipulate data in the data file (read or write) will be temporarily stopped/blocked until reindexing is complete.
    HFSQL Client/Server If the hBackgroundTask constant is used, the reindexing process is run in the background and the applications that use the data file are not stopped.
If an error occurs during the automatic reindex operation (lock error on the data file or on the record for example), the automatic reindex operation is stopped and a fatal error (corrupted index) is displayed. This operating mode is similar to the one without automatic reindexing.
Remarks:
  • During the automatic reindexing, the reindex operation is performed in normal mode (hNdxNormal constant).
  • Automatic reindexing is not available for Hyper File 5.5 data files.
  • If an automatic reindexing is performed, the applications that use the data files currently reindexed are temporarily locked. A message appears, indicating that the data file is under maintenance.
  • Once reindexing is completed, the current HFSQL context is automatically restored (except for reindexing with memo item verification).
WINDEVWEBDEV - Server codeReports and QueriesAndroidAndroid Widget iPhone/iPadJavaUser code (UMC)AjaxHFSQL ClassicHFSQL Client/Server

"Zero-downtime" reindexing

A data file can be reindexed even when it is accessed by one or more applications.
Any applications that manipulate data in the data file (read or write) will be temporarily stopped/blocked until reindexing is complete.
WINDEV A window is displayed, indicating that the data file is currently reindexed (also called reorganization). This window is displayed during reindexing and cannot be closed. A progress bar indicates the status of reindex operation.
You can customize this window or don't allow it to open again. For more details, see HFSQL error handling help.
To avoid flickering issues, the indexing window is displayed only if the reindexing process takes more than 2 seconds. In this case, this window is displayed after 0.7 seconds.
Note: "Hot" reindexing is not available if records are locked for read or write operations in the data file to be reindexed. If records are locked in write mode only, zero-downtime reindexing can still be performed.
HFSQL Client/Server If the hBackgroundTask constant is used, the reindexing process is run in the background and the applications that use the data file are not stopped.

Calculating statistics

Statistics help optimize queries and filters in the data file. Only active records are taken into account for calculating statistics. HStatCalculate also returns the results of this calculation.
Note: For optimal results, this calculation must include all data files (e.g. multi-file query).

Directory of temporary files

Temporary files can be created during reindexing. By default, these files are created in the Windows temporary directory or in the current directory if there is not enough space.
The H.TemporaryDirectory variable allows you to configure the directory used to save these temporary files. This variable is recommended when reindexing large data files.
HFSQL Client/Server The directory used to store temporary files on the server can be defined as follows:

Managing non-Latin character sets

To modify the character set used for the searches, the sorts:
  1. Specify the character set to use with ChangeCharset.
  2. Reindex the data file with HIndex. Use the hChangeCharset constant to use the character set specified by ChangeCharset.
For more details, see Managing specific character sets in the data files.

Access rights to the data file

Reindexing recreates the data file on disk. In an allocation system that manages permissions at file level (NTFS, etc.), the reindexed data file will have the permissions of the directory to which it belongs.
If the data file had different rights from those of the folder before reindexing, you must redefine them in Windows after reindexing.

Special case: Data files corrupted after a reboot or a fatal error

Some data files may be corrupted when the computer reboots unexpectedly. In this case, the data files contain invalid data (unreadable characters for example). To fix this problem:
  1. Perform a reindexing with deletion.
  2. Free all records held by a transaction with HTransactionFree.
  3. Delete the incorrect records with WDMAP.
WINDEV

Previous versions

This function replaces HIndex_55, which is kept for compatibility with WINDEV 5.5.
Business / UI classification: Business Logic
Component: wd300hf.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 10/01/2025

Send a report | Local help