Last updated: 20 Aug 2004 by XpertSS.com
You may be able to significantly reduce the file sizes for your database depending on how your application uses your databases. This process is called "compressing" the database. But you may not see any change in the file sizes at all. Consider these two situations:
1) If you do not delete records from your database, there will not be any change in the .dbf or .dbt file size after compressing it. You will see a reduction in the size of the SmartIndex .adx file because all indexes not needed to support the current .APR file's joins will be eliminated. Approach will rebuild them when needed.
2) If you do delete records from your database, the records are only marked as deleted when you do that. They are not actually removed from the .dbf file. Therefore the .dbf is still the same size after you delete records. And any memo or PicturePlus fields are still in the .dbt, but the pointers to them are removed from the deleted record in the .dbf.
To actually remove deleted records from the database you need to "compress" the database. This removes the records in the .dbf, the memo and PicturePlus fields in the .dbt, and unnecessary indexes in the .adx file. In v96 and newer releases, you do this in Approach by going to the File menu, User Setup option, Approach Preferences option, and then select the Database tab. Then choose the database file name that you want to compress and click on the "Compress" button. This flags that you want it compressed, but Approach does not actually compress it until you press "OK". If you want to compress several databases files, you need to select and click the "Compress" button for each one and then click "OK". You need to be the only user of a database when you do this.
See article 'Compressing databases with a macro or script' in this FAQ to automate this procedure.
Once a database is compressed, deleted records cannot be recovered (see article 'Recovering deleted records' in this FAQ). For this reason, it is highly recommended that you create a backup copy of your files before doing this.
Are there other reasons for compressing a database? Yes! A compressed database is more efficient in its indexing which speeds up your Finds. And if you don't ever compress a database then it is more likely to develop index errors or corruption. Some report they never compress their databases and they run fine that way for years, however!