PRAGMA analysis_limit
Query or change a limit on the approximate ANALYZE setting.
PRAGMA analysis_limit; PRAGMA analysis_limit = N;
On the sample database
What PRAGMA analysis_limit returns on the sample database, in SQLite 3.54.1 as built for the browser by sql.js:
| analysis_limit |
|---|
| 0 |
What the SQLite documentation says
Query or change a limit on the approximate ANALYZE setting. This is the approximate number of rows examined in each index by the ANALYZE command. If the argument N is omitted, then the analysis limit is unchanged. If the limit is zero, then the analysis limit is disabled and the ANALYZE command will examine all rows of each index. If N is greater than zero, then the analysis limit is set to N and subsequent ANALYZE commands will stop analyzing each index after it has examined approximately N rows. If N is a negative number or something other than an integer value, then the pragma behaves as if the N argument was omitted. In all cases, the value returned is the new analysis limit used for subsequent ANALYZE commands.
This pragma can be used to help the ANALYZE command run faster on large databases. The results of analysis are not as good when only part of each index is examined, but the results are usually good enough. Setting N to 100 or 1000 allows the ANALYZE command to run quickly, even on enormous database files.
This pragma was added in SQLite version 3.32.0 (2020-05-22). The current implementation only uses the lower 31 bits of the N value - higher order bits are silently ignored. Future versions of SQLite might begin using higher order bits.
Beginning with SQLite version 3.46.0 (2024-05-23), the recommended way of running ANALYZE is with the PRAGMA optimize command. The PRAGMA optimize will automatically set a reasonable, temporary analysis limit that ensures that the PRAGMA optimize command will finish quickly even on enormous databases. Applications that use the PRAGMA optimize instead of running ANALYZE directly do not need to set an analysis limit.
From sqlite.org's pragma documentation for SQLite 3.54.1, in the public domain.