Skip to main content
These settings are available in system.settings and are autogenerated from source.

log_query_plans

Write the query plan that was executed, together with its per-step runtime statistics, to the query_plan column of system.query_log. The column has the JSON type, so the statistics are stored as numbers and can be aggregated by a query rather than only read. The plan carries the same information EXPLAIN ANALYZE shows — the tree of steps, what each step does, and per-step rows, bytes, wall-clock time and parallelism. Only SELECT queries executed with the analyzer (enable_analyzer = 1, the default) are captured, and only where the row itself is written, so log_queries must also be enabled. A query that failed during execution is captured with the plan it was running but without statistics. The column is empty on QueryStart rows, because no plan exists yet when they are written. Enabling this setting makes the captured query collect per-processor timings, which is the same instrumentation log_processors_profiles uses, so it is not free. Queries that are not captured are unaffected. That cost is decided before the query runs, so a captured query pays it even where its row is dropped afterwards by log_queries_min_type or log_queries_min_query_duration_ms — neither is knowable that early. A query answered from the query cache executes no plan and so has none to store. It also causes step descriptions produced by plan optimizations (for example merged expressions) to be retained rather than discarded, which makes them visible in system.processors_profile_log.plan_step_description as well. See also:

log_query_plans_max_size

Maximum size, in bytes, of the document written to the query_plan column of system.query_log by log_query_plans. A query decides how much text its own plan contains: a large IN list, a long alias or a folded constant are all rendered into it. This bounds what one query can store on its row, and the document is written into a buffer of this size, so it also bounds what rendering one plan can allocate. A plan that does not fit is not stored truncated, because half a document is not a plan. The column holds the reason instead, as {"Error": ...}. 0 means no limit.

log_query_settings

Log query settings into the query_log and OpenTelemetry span log.

log_query_threads

Setting up query threads logging. Query threads log into the system.query_thread_log table. This setting has effect only when log_queries is true. Queries’ threads run by ClickHouse with this setup are logged according to the rules in the query_thread_log server configuration parameter. Possible values:
  • 0 — Disabled.
  • 1 — Enabled.
Example

log_query_views

Setting up query views logging. When a query run by ClickHouse with this setting enabled has associated views (materialized or live views), they are logged in the query_views_log server configuration parameter. Example: