SQLite User Forum

Analyze and the TEMP schema
Login

Analyze and the TEMP schema

(1) By anonymous on 2024-04-03 22:03:33 [link] [source]

If I have one or more temp tables and I execute the ANALYZE; statement, no statistics tables are created in the TEMP schema. This leads me to assume that no analysis of the temp tables has occurred. The statistics tables are not created until I execute ANALYZE TEMP;. The documentation, which says If no arguments are given, all attached databases are analyzed. implies that the TEMP schema will be analyzed, but I am assuming that SQLite is behaving as intended. If so, could the documentation please be updated to clarify?

Once the TEMP schema has been analyzed, will future ANALYZE; statements also analyze the TEMP schema (once the statistics tables are there) or is ANALYZE TEMP; always required to update statistics on the TEMP schema?

Once the TEMP schema has been analyzed, does ANALYZE sqlite_schema; also reload the analysis data from the TEMP schema or do I also need to do an explicit ANALYZE temp.sqlite_schema;? (And could the documentation please be updated to clarify this as well?)

Thank you.

(2) By Adrian Ho (lexfiend) on 2024-04-04 15:47:09 in reply to 1 [source]

The documentation, which says If no arguments are given, all attached databases are analyzed. implies that the TEMP schema will be analysed

You're assuming TEMP is an attached database. Section 2 of ATTACH DATABASE says otherwise:

The main and temp databases cannot be attached or detached.

I suppose if one wanted to be pedantic, the statement you quoted might be clarified as:

If no arguments are given, all attached databases are analysed in addition to the main database.