This SQLite post explains how to use the SQLite ANALYZE command with syntax and examples.
The SQLite ANALYZE command is used to calculate and store statistical information about the tables and indexes analyzed. The statistical information gathered will be stored in a system table called sqlite_stat1 and will be later used by the query optimizer to determine the most efficient query plan.
The syntax for the ANALYZE command in SQLite is:
Optional. The name of the database to analyze.
Optional. The name of the table to analyze.
The ANALYZE command is most commonly run with no parameters. When no parameters are provided, the ANALYZE command will gather statistical information about all of the indexes in all of the attached databases.
For example:
This example would store all of the statistical information for all indexes in the sqlite_stat1 system table.
If you specify ANALYZE with a database name, the ANALYZE command will gather statistical information for all of the indexes in the specified database.
For example:
This example would analyze all of the indexes in the database called AODBA and store the statistical information in the sqlite_stat1 system table.
Finally, if you can specify ANALYZE with a table name, the ANALYZE command will gather statistical information for all of the indexes in the specified table.
For example:
This example would analyze all of the indexes in the table called suppliers and store the statistical information in the sqlite_stat1 system table.