Help wanted!

The following content of this documentation page has been machine-translated. But unlike other websites, it is not done on the fly. This translated text lives on GitHub repository alongside main ClickHouse codebase and waits for fellow native speakers to make it more human-readable. You can also use the original English version as a reference.

Help ClickHouse documentation by editing this page

系统。query_thread_log

包含有关执行查询的线程的信息,例如,线程名称、线程开始时间、查询处理的持续时间。

开始记录:

  1. 在配置参数 query_thread_log 科。
  2. 设置 log_query_threads 到1。

数据的冲洗周期设置在 flush_interval_milliseconds 的参数 query_thread_log 服务器设置部分。 要强制冲洗,请使用 SYSTEM FLUSH LOGS 查询。

ClickHouse不会自动从表中删除数据。 看 导言 欲了解更多详情。

列:

  • event_date (日期) — The date when the thread has finished execution of the query.
  • event_time (日期时间) — The date and time when the thread has finished execution of the query.
  • query_start_time (日期时间) — Start time of query execution.
  • query_duration_ms (UInt64) — Duration of query execution.
  • read_rows (UInt64) — Number of read rows.
  • read_bytes (UInt64) — Number of read bytes.
  • written_rows (UInt64) — For INSERT 查询,写入的行数。 对于其他查询,列值为0。
  • written_bytes (UInt64) — For INSERT 查询时,写入的字节数。 对于其他查询,列值为0。
  • memory_usage (Int64) — The difference between the amount of allocated and freed memory in context of this thread.
  • peak_memory_usage (Int64) — The maximum difference between the amount of allocated and freed memory in context of this thread.
  • thread_name (字符串) — Name of the thread.
  • thread_number (UInt32) — Internal thread ID.
  • thread_id (Int32) — thread ID.
  • master_thread_id (UInt64) — OS initial ID of initial thread.
  • query (字符串) — Query string.
  • is_initial_query (UInt8) — Query type. Possible values:
    • 1 — Query was initiated by the client.
    • 0 — Query was initiated by another query for distributed query execution.
  • user (字符串) — Name of the user who initiated the current query.
  • query_id (字符串) — ID of the query.
  • address (IPv6) — IP address that was used to make the query.
  • port (UInt16) — The client port that was used to make the query.
  • initial_user (字符串) — Name of the user who ran the initial query (for distributed query execution).
  • initial_query_id (字符串) — ID of the initial query (for distributed query execution).
  • initial_address (IPv6) — IP address that the parent query was launched from.
  • initial_port (UInt16) — The client port that was used to make the parent query.
  • interface (UInt8) — Interface that the query was initiated from. Possible values:
    • 1 — TCP.
    • 2 — HTTP.
  • os_user (字符串) — OS’s username who runs ツ环板clientョツ嘉ッツ偲.
  • client_hostname (字符串) — Hostname of the client machine where the ツ环板clientョツ嘉ッツ偲 或者运行另一个TCP客户端。
  • client_name (字符串) — The ツ环板clientョツ嘉ッツ偲 或另一个TCP客户端名称。
  • client_revision (UInt32) — Revision of the ツ环板clientョツ嘉ッツ偲 或另一个TCP客户端。
  • client_version_major (UInt32) — Major version of the ツ环板clientョツ嘉ッツ偲 或另一个TCP客户端。
  • client_version_minor (UInt32) — Minor version of the ツ环板clientョツ嘉ッツ偲 或另一个TCP客户端。
  • client_version_patch (UInt32) — Patch component of the ツ环板clientョツ嘉ッツ偲 或另一个TCP客户端版本。
  • http_method (UInt8) — HTTP method that initiated the query. Possible values:
    • 0 — The query was launched from the TCP interface.
    • 1 — GET 方法被使用。
    • 2 — POST 方法被使用。
  • http_user_agent (字符串) — The UserAgent http请求中传递的标头。
  • quota_key (字符串) — The “quota key” 在指定 配额 设置(见 keyed).
  • revision (UInt32) — ClickHouse revision.
  • ProfileEvents.Names (数组(字符串)) — Counters that measure different metrics for this thread. The description of them could be found in the table 系统。活动.
  • ProfileEvents.Values (数组(UInt64)) — Values of metrics for this thread that are listed in the ProfileEvents.Names 列。

示例

  1. SELECT * FROM system.query_thread_log LIMIT 1 FORMAT Vertical
  1. Row 1:
  2. ──────
  3. event_date: 2020-05-13
  4. event_time: 2020-05-13 14:02:28
  5. query_start_time: 2020-05-13 14:02:28
  6. query_duration_ms: 0
  7. read_rows: 1
  8. read_bytes: 1
  9. written_rows: 0
  10. written_bytes: 0
  11. memory_usage: 0
  12. peak_memory_usage: 0
  13. thread_name: QueryPipelineEx
  14. thread_id: 28952
  15. master_thread_id: 28924
  16. query: SELECT 1
  17. is_initial_query: 1
  18. user: default
  19. query_id: 5e834082-6f6d-4e34-b47b-cd1934f4002a
  20. address: ::ffff:127.0.0.1
  21. port: 57720
  22. initial_user: default
  23. initial_query_id: 5e834082-6f6d-4e34-b47b-cd1934f4002a
  24. initial_address: ::ffff:127.0.0.1
  25. initial_port: 57720
  26. interface: 1
  27. os_user: bayonet
  28. client_hostname: clickhouse.ru-central1.internal
  29. client_name: ClickHouse client
  30. client_revision: 54434
  31. client_version_major: 20
  32. client_version_minor: 4
  33. client_version_patch: 1
  34. http_method: 0
  35. http_user_agent:
  36. quota_key:
  37. revision: 54434
  38. ProfileEvents.Names: ['ContextLock','RealTimeMicroseconds','UserTimeMicroseconds','OSCPUWaitMicroseconds','OSCPUVirtualTimeMicroseconds']
  39. ProfileEvents.Values: [1,97,81,5,81]
  40. ...

另请参阅

  • 系统。query_log — Description of the query_log 系统表,其中包含有关查询执行的公共信息。