system.query_log

- `hostname` ([LowCardinality(String)](/docs/sql-reference/data-types/string)) — Hostname of the server executing the query.
- `type` ([Enum8](/docs/sql-reference/data-types/enum)) — Type of an event that occurred when executing the query. Values:
  - `'QueryStart' = 1` — Successful start of query execution.
  - `'QueryFinish' = 2` — Successful end of query execution.
  - `'ExceptionBeforeStart' = 3` — Exception before the start of query execution.
  - `'ExceptionWhileProcessing' = 4` — Exception during the query execution.
- `event_date` ([Date](/docs/sql-reference/data-types/date)) — Query starting date.
- `event_time` ([DateTime](/docs/sql-reference/data-types/datetime)) — Query starting time.
- `event_time_microseconds` ([DateTime64](/docs/sql-reference/data-types/datetime64)) — Query starting time with microseconds precision.
- `query_start_time` ([DateTime](/docs/sql-reference/data-types/datetime)) — Start time of query execution.
- `query_start_time_microseconds` ([DateTime64](/docs/sql-reference/data-types/datetime64)) — Start time of query execution with microsecond precision.
- `query_duration_ms` ([UInt64](/docs/sql-reference/data-types/int-uint#integer-ranges)) — Duration of query execution in milliseconds.
- `read_rows` ([UInt64](/docs/sql-reference/data-types/int-uint#integer-ranges)) — Total number of rows read from all tables and table functions participated in query. It includes usual subqueries, subqueries for `IN` and `JOIN`. For distributed queries `read_rows` includes the total number of rows read at all replicas. Each replica sends it's `read_rows` value, and the server-initiator of the query summarizes all received and local values. The cache volumes do not affect this value.
- `read_bytes` ([UInt64](/docs/sql-reference/data-types/int-uint#integer-ranges)) — Total number of bytes read from all tables and table functions participated in query. It includes usual subqueries, subqueries for `IN` and `JOIN`. For distributed queries `read_bytes` includes the total number of rows read at all replicas. Each replica sends it's `read_bytes` value, and the server-initiator of the query summarizes all received and local values. The cache volumes do not affect this value.
- `written_rows` ([UInt64](/docs/sql-reference/data-types/int-uint#integer-ranges)) — For `INSERT` queries, the number of written rows. For other queries, the column value is 0.
- `written_bytes` ([UInt64](/docs/sql-reference/data-types/int-uint#integer-ranges)) — For `INSERT` queries, the number of written bytes (uncompressed). For other queries, the column value is 0.
- `result_rows` ([UInt64](/docs/sql-reference/data-types/int-uint#integer-ranges)) — Number of rows in a result of the `SELECT` query, or a number of rows in the `INSERT` query.
- `result_bytes` ([UInt64](/docs/sql-reference/data-types/int-uint#integer-ranges)) — RAM volume in bytes used to store a query result.
- `memory_usage` ([UInt64](/docs/sql-reference/data-types/int-uint#integer-ranges)) — Memory consumption by the query.
- `current_database` ([String](/docs/sql-reference/data-types/string)) — Name of the current database.
- `query` ([String](/docs/sql-reference/data-types/string)) — Query string.
- `formatted_query` ([String](/docs/sql-reference/data-types/string)) — Formatted query string.
- `normalized_query_hash` ([UInt64](/docs/sql-reference/data-types/int-uint#integer-ranges)) — A numeric hash value, such as it is identical for queries differ only by values of literals.
- `query_kind` ([LowCardinality(String)](/docs/sql-reference/data-types/lowcardinality)) — Type of the query.
- `databases` ([Array](/docs/sql-reference/data-types/array)([LowCardinality(String)](/docs/sql-reference/data-types/lowcardinality))) — Names of the databases present in the query.
- `tables` ([Array](/docs/sql-reference/data-types/array)([LowCardinality(String)](/docs/sql-reference/data-types/lowcardinality))) — Names of the tables present in the query.
- `columns` ([Array](/docs/sql-reference/data-types/array)([LowCardinality(String)](/docs/sql-reference/data-types/lowcardinality))) — Names of the columns present in the query.
- `partitions` ([Array](/docs/sql-reference/data-types/array)([LowCardinality(String)](/docs/sql-reference/data-types/lowcardinality))) — Names of the partitions present in the query.
- `projections` ([String](/docs/sql-reference/data-types/string)) — Names of the projections used during the query execution.
- `views` ([Array](/docs/sql-reference/data-types/array)([LowCardinality(String)](/docs/sql-reference/data-types/lowcardinality))) — Names of the (materialized or live) views present in the query.
- `exception_code` ([Int32](/docs/sql-reference/data-types/int-uint)) — Code of an exception.
- `exception` ([String](/docs/sql-reference/data-types/string)) — Exception message.
- `stack_trace` ([String](/docs/sql-reference/data-types/string)) — [Stack trace](https://en.wikipedia.org/wiki/Stack_trace). An empty string, if the query was completed successfully.
- `is_initial_query` ([UInt8](/docs/sql-reference/data-types/int-uint)) — Query type. Possible values:
  - 1 — Query was initiated by the client.
  - 0 — Query was initiated by another query as part of distributed query execution.
- `connection_address` ([IPv6](/docs/sql-reference/data-types/ipv6)) — The client IP address from which the connection was made. When connected through a proxy this will be the address of the proxy.
- `connection_port` ([UInt16](/docs/sql-reference/data-types/int-uint)) — The client port from which the connection was made. When connected through a proxy this will be the port of the proxy.
- `user` ([String](/docs/sql-reference/data-types/string)) — Name of the user who initiated the current query.
- `query_id` ([String](/docs/sql-reference/data-types/string)) — ID of the query.
- `address` ([IPv6](/docs/sql-reference/data-types/ipv6)) — The IP address that was used to make the query. When connected through a proxy and [auth\_use\_forwarded\_address](/docs/operations/server-configuration-parameters/settings#auth_use_forwarded_address) is set this will be the address of the client instead of the proxy.
- `port` ([UInt16](/docs/sql-reference/data-types/int-uint#integer-ranges)) — The client port that was used to make the query. When connected through a proxy and [auth\_use\_forwarded\_address](/docs/operations/server-configuration-parameters/settings#auth_use_forwarded_address) is set this will be the port of the client instead of the proxy.
- `initial_user` ([String](/docs/sql-reference/data-types/string)) — Name of the user who ran the initial query (for distributed query execution).
- `initial_query_id` ([String](/docs/sql-reference/data-types/string)) — ID of the initial query (for distributed query execution).
- `initial_address` ([IPv6](/docs/sql-reference/data-types/ipv6)) — IP address that the parent query was launched from.
- `initial_port` ([UInt16](/docs/sql-reference/data-types/int-uint)) — The client port that was used to make the parent query.
- `initial_query_start_time` ([DateTime](/docs/sql-reference/data-types/datetime)) — Initial query starting time (for distributed query execution).
- `initial_query_start_time_microseconds` ([DateTime64](/docs/sql-reference/data-types/datetime64)) — Initial query starting time with microseconds precision (for distributed query execution).
- `interface` ([UInt8](/docs/sql-reference/data-types/int-uint)) — Interface that the query was initiated from. Possible values:
  - 1 — TCP.
  - 2 — HTTP.
- `os_user` ([String](/docs/sql-reference/data-types/string)) — Operating system username who runs [clickhouse-client](/docs/interfaces/client).
- `client_hostname` ([String](/docs/sql-reference/data-types/string)) — Hostname of the client machine where the [clickhouse-client](/docs/interfaces/client) or another TCP client is run.
- `client_name` ([String](/docs/sql-reference/data-types/string)) — The [clickhouse-client](/docs/interfaces/client) or another TCP client name.
- `client_revision` ([UInt32](/docs/sql-reference/data-types/int-uint)) — Revision of the [clickhouse-client](/docs/interfaces/client) or another TCP client.