The sql_optimize() function is used to optimise an SQL table. This function is called by the optimiser_base_une_table() function which is periodically called by the cron mechanism. Please refer to the OPTIMIZE TABLE or VACUUM commands for the appropriate SQL database manager to understand the details of what is being executed by these commands.

The function accepts 3 parameters:

  1. $table is the name of the table to be optimised,
  2. $serveur,
  3. $option.



Note: SQLite can not optimise one table at a time, but optimises the entire database in one hit. In this case, if the sql_optimize() function is called multiple times in a row, then the operation will actually only be performed just once for the first call.

Author Mark Baber Published : Updated : 12/03/23

Translations : English, français