F.31. online_analyze
The online_analyze module provides a set of features that immediately update statistics after INSERT, UPDATE, DELETE, SELECT INTO, or COPY operations for the affected tables.
Note
Temporary tables cannot be accessed by autovacuum, and 1C solutions use them extensively. Historically, online_analyze was designed specifically for 1C and used to keep statistics on temporary tables up to date. For 1C:Enterprise version 8.3.13 and later, this module is not needed because 1C:Enterprise automatically performs ANALYZE after each insert into a temporary table.
Statistics on persistent tables are collected by autovacuum so analyzing them with online_analyze is rarely needed, and immediate statistics updates can slow down query execution. This is why the module is disabled by default. Once enabled, it analyzes only temporary tables. However, you can enable it if background updates do not provide the desired result or if the optimizer frequently fails to estimate the row count.
The instruction below is relevant only if you decide to use the module.
F.31.1. Module Loading
To use online_analyze module, load the shared library:
LOAD 'online_analyze';
After loading, the module remains disabled until you set online_analyze.enable to on. For details, refer to Section F.31.2.
F.31.2. Module Configuration
You can configure online_analyze using the following custom variables (default values are shown):
online_analyze.enable = off
Enables
online_analyze. This parameter is disabled by default. Set it toon, if needed.online_analyze.verbose = on
Executes
ANALYZE VERBOSE.Note
Since
verboseis a reserved SQL key word, this parameter has to be double-quoted when used in SQL queries. For example:ALTER SYSTEM SET "online_analyze.verbose" = 'off';
online_analyze.scale_factor = 0.1
Fraction of table size to start online analysis (similar to autovacuum_analyze_scale_factor).
online_analyze.threshold = 50
Minimum number of row updates before starting online analysis (similar to autovacuum_analyze_threshold).
online_analyze.min_interval = 10000
Minimum time interval between
ANALYZEcalls per table, in milliseconds.online_analyze.table_type = "all"
Type(s) of tables for online analysis. Possible values are:
all,persistent,temporary,none.online_analyze.exclude_tables = ""
List of tables to exclude from online analysis.
online_analyze.include_tables = ""
List of tables to include in online analysis (
online_analyze.include_tablesoverridesonline_analyze.exclude_tables).online_analyze.local_tracking = off
Enables per-backend tracking for temporary tables by
online_analyze. When this variable is set tooff,online_analyzeuses the default system statistics for temporary tables.online_analyze.lower_limit = 0
Minimum number of rows in a table required to trigger
online_analyze.online_analyze.capacity_threshold = 100000
Maximum number of temporary tables to store in local cache.
F.31.3. Authors
Teodor Sigaev <teodor@sigaev.ru>