If I create a table in SQLite that has only the PRIMARY KEY index, is there any role for running ANALYZE after a bulk insert, or will that key automatically have been kept up-to-date by necessity? In this case, I am inserting all data at once, and there will never be any records that are deleted.
What if the scenario is slightly different: the table is WITHOUT ROWID, and the PRIMARY KEY is a clustered index on several columns — does that change the wisdom here?
Best Answer
The documentation says:
Here, "significantly" means that the new data changes the characteristics so much that the index is no longer as useful, or that it is much more useful than previously.
However, for a primary key, the selectivity usually does not change, so it should not be necessary to run ANALYZE after larger inserts.
(With or WITHOUT ROWID does not make any difference for this.)