Help Center/TaurusDB/FAQs/Database Usage/How Do I Use ANALYZE & OPTIMIZE?
Updated on 2026-04-02 GMT+08:00

How Do I Use ANALYZE & OPTIMIZE?

This section describes FAQs about using ANALYZE & OPTIMIZE.

Why Does the Space Usage Not Decrease After Data Is Deleted?

TaurusDB optimizes space management for deleted data. By default, the space occupied by deleted data is not immediately released but is retained for future writes.

To release the space immediately, you are advised to run OPTIMIZE TABLE tableName during off-peak hours.

Comparison Between ANALYZE TABLE and OPTIMIZE TABLE

Table 1 Comparison between ANALYZE TABLE and OPTIMIZE TABLE

Item

ANALYZE TABLE

OPTIMIZE TABLE

Description

This statement updates table statistics. It is usually used to address issues such as SQL queries choosing incorrect indexes due to outdated statistics.

This statement not only updates statistics but also releases fragmented space. It is usually used to address excessive fragmented space in a table.

Execution Duration

Within seconds

The duration depends on the table data volume, instance specifications, and workloads. You are advised to execute this statement during off-peak hours.

Table Locking Duration

Within seconds

Within seconds