Sometimes indices get corrupted and exhibit unexpected results, such as, returning the incorrect selection of records. One way of dealing with this problem is to reindex the index. There are few ways to reindex. The approach presented in this tech tip is to remove the index (or indices) and let 4D rebuild it (them).
When reindexing a problem index, it is preferrable to reindex all related indices. If all indices for a table are not removed and rebuilt, sometimes a problem with an index will persist after the index is recreated.
One convenient way of reindexing multiple indices in a data file is to work with 2 copies of the structure file. One copy of the structure file will be remain the same -- we will refer to this as the 'original' copy of the structure file. The second copy of the structure file will be referred to as the 'deindex' copy -- this is used to deindex the data file.
The steps are:
- Open the deindex structure file with a new data file.
- Go to the design mode and open the structure editor.
- Remove all the indexes that you want to rebuild.
- Open the old data file with the deindex structure file.
- 4D will automatically remove all the indices. (This may take several minutes)
- Quit 4D. Again this may take a while as 4D might need time to write all the changes to the hard drive.
- Open the original copy of the structure file with the old data file that was just deindexed.
- 4D will automatically recreate the indexes.