Skip to main content
You can use functions described in this chapter to introspect ELF and DWARF for query profiling.
These functions are slow and may impose security considerations.
For proper operation of introspection functions:
  • Install the clickhouse-common-static-dbg package.
  • Set the allow_introspection_functions setting to 1. For security reasons introspection functions are disabled by default.
ClickHouse saves profiler reports to the trace_log system table. Make sure the table and profiler are configured properly.

addressToLine

Introduced in: v20.1.0 Converts an address of an instruction inside the main ClickHouse executable to a filename and line number in ClickHouse’s source code. The address must be an offset inside the main ClickHouse executable, the form in which addresses are stored in the trace columns of system.trace_log, system.stack_trace, and system.crash_log, and the last_error_trace column of system.error_log. Runtime (virtual memory) addresses are not accepted, so that the function cannot be used to learn the memory layout of the server process. Frames outside the main executable are stored as 0, and the function returns an empty result for them.
This function is slow and may impose security considerations.
To enable this introspection function:
This function is non-deterministic: it can return different results for the same arguments.
Syntax
Arguments
  • address_of_binary_instruction — Offset of an instruction inside the main ClickHouse executable, as stored in the trace column of system.trace_log and similar tables. UInt64
Returned value Returns a source code filename and line number delimited by a colon, for example, /build/obj-x86_64-linux-gnu/../src/Common/ThreadPool.cpp:199. Returns the name of the binary, if no debug information could be found for the address, or an empty string for 0. String Examples Selecting the first string from the trace_log system table
Query
Response
Getting the source code filename and the line number for a single address
Query
Response
Applying the function to the whole stack trace
Query
Response

addressToLineWithInlines

Introduced in: v22.2.0 Similar to addressToLine, but returns an Array with all inline functions. As a result of this, it is slower than addressToLine. The address must be an offset inside the main ClickHouse executable, the form in which addresses are stored in the trace columns of system.trace_log, system.stack_trace, and system.crash_log, and the last_error_trace column of system.error_log. Runtime (virtual memory) addresses are not accepted, so that the function cannot be used to learn the memory layout of the server process. Frames outside the main executable are stored as 0, and the function returns an empty result for them. To enable this introspection function:
This function is non-deterministic: it can return different results for the same arguments.
Syntax
Arguments
  • address_of_binary_instruction — Offset of an instruction inside the main ClickHouse executable, as stored in the trace column of system.trace_log and similar tables. UInt64
Returned value Returns an array whose first element is the source code filename and line number delimited by a colon. The second, third, etc. element list inline functions’ source code filenames, line numbers and function names. If no debug information could be found, then an array with a single element equal to the name of the binary is returned, otherwise an empty array is returned for 0. Array(String) Examples Applying the function to an address
Query
Response
Applying the function to the whole stack trace
Query
Response

addressToSymbol

Introduced in: v20.1.0 Converts an address of an instruction inside the main ClickHouse executable to a symbol from ClickHouse’s object files. The address must be an offset inside the main ClickHouse executable, the form in which addresses are stored in the trace columns of system.trace_log, system.stack_trace, and system.crash_log, and the last_error_trace column of system.error_log. Runtime (virtual memory) addresses are not accepted, so that the function cannot be used to learn the memory layout of the server process. Frames outside the main executable are stored as 0, and the function returns an empty result for them.
This function is non-deterministic: it can return different results for the same arguments.
Syntax
Arguments
  • address_of_binary_instruction — Offset of an instruction inside the main ClickHouse executable, as stored in the trace column of system.trace_log and similar tables. UInt64
Returned value Returns the symbol from ClickHouse object files or an empty string, if the address is not valid or is 0. String Examples Selecting the first string from the trace_log system table
Query
Response
Getting a symbol for a single address
Query
Response
Applying the function to the whole stack trace
Query
Response

demangle

Introduced in: v20.1.0 Converts a symbol to a C++ function name. The symbol is usually returned by function addressToSymbol. Syntax
Arguments
  • symbol — Symbol from an object file. String
Returned value Returns the name of the C++ function, or an empty string if the symbol is not valid. String Examples Selecting the first string from the trace_log system table
Query
Response
Getting a function name for a single address
Query
Response
Applying the function to the whole stack trace
Query
Response

isMergeTreePartCoveredBy

Introduced in: v25.6.0 Function which checks if the part of the first argument is covered by the part of the second argument. Syntax
Arguments
  • nested_part — Name of expected nested part. String
  • covering_part — Name of expected covering part. String
Returned value Returns 1 if it covers, 0 otherwise. UInt8 Examples Basic example
Query
Response

logTrace

Introduced in: v20.12.0 Emits a trace log message to the server log. The function accepts a constant argument only, so the call is evaluated during query analysis and replaced by its result. The message is therefore emitted once while the query is analyzed, and not once per processed Block: the number of rows and the setting max_block_size have no effect on how many messages appear in the log. Syntax
Arguments
  • message — Message that is emitted to the server log. const String
Returned value Returns 0 always. UInt8 Examples Basic example
Query
Response

mergeTreePartInfo

Introduced in: v25.6.0 Function that helps to cut the useful values out of the MergeTree part name. Syntax
Arguments
  • part_name — Name of part to unpack. String
Returned value Returns a Tuple with subcolumns: partition_id, min_block, max_block, level, mutation. Tuple Examples Basic example
Query
Response

tid

Introduced in: v20.12.0 Returns id of the thread, in which the current Block is processed. Syntax
Arguments
  • None.
Returned value Returns the current thread id. UInt64 Examples Usage example
Query
Response