SQLite Forum

Runtime of and opcode counts of ANALYZE
Login
Is the excess time being used by integrity_check or ANALYZE?

My guess would be integrity_check, as that is an O(NlogN) operation whereas
ANALYZE is O(N).

Have you considered running "PRAGMA quick_check(100)" instead of
"PRAGMA integrity_check(100)"?  The difference is that quick_check
will not cross-check tables and indexes.  In other words, quick_check
does not verify that every table entry has all the correct index entries,
and that every index entry corresponds to exactly one table entry.
Quick_check verifies that each table and index is self-consistent, but
it does not verify cross-consistency.  The lack of cross-checking
means that quick_check is able to run in O(N) time.