optimize
Runs database optimization tasks.
This pragma instructs the query planner to gather statistics and perform other optimizations to improve the performance of future queries. By default, it runs all available optimization tasks. An optional mask can be provided to run a specific subset of tasks.
The available optimizations are:
0x00001- ANALYZE: Gathers statistics on tables and indices. This is equivalent to running theANALYZEcommand. It helps the query planner make better choices.0x00002- SORT_NDX: Reorganizes b-tree pages in indices to make access more efficient, similar to aREINDEXoperation. This is useful after manyDELETEs orUPDATEs.0x00004- PAGES: Reorganizes b-tree pages in tables. This may help improve data locality and reduce query times.
The pragma returns a cursor with a single column containing a human-readable log of the optimizations that were performed. If the database is busy, some optimizations might be skipped.
Return
A KQLiteCursor containing a log of the optimization activities.
Author
MOHAMMAD AZIM ANSARI
Parameters
An optional integer bitmask to specify which optimizations to run. If null (the default), all available optimizations are attempted.