For B-tree indexes, a large number of index keys on the index page will be deleted after
multiple delete or update operations on a database table. This results in index bloat. Therefore,
periodically rebuilding indexes can improve query efficiency.
LibrA supports the REINDEX statement for rebuilding indexes, but the execution is timeconsuming.
In practice, you can copy and save all B-tree index definitions from table-related
DDL statements, run the DROP INDEX statement to delete the corresponding indexes, reexecute
the saved index definitions, and rebuild these indexes.
Pay attention to the following when rebuilding an index:
l GIN or psort indexes do not need to be periodically rebuilt after being created.
l Set the execution interval of index rebuilding to once a month, and select a night period
(from 20:00 to 6:00 the next day) when system load is low. Running the crontab
command to periodically execute the GSQL script can be used as a reference.
l Before rebuilding an index, test and evaluate the operation time and ensure that the
operation can be completed within a specified time window.