> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-mintlify-8a08bda2.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> 쿼리를 실행하는 스레드 정보를 포함하는 시스템 테이블로, 예를 들어 스레드 이름, 스레드 시작 시간, 쿼리 처리 소요 시간 등의 정보를 제공합니다.

# system.query_thread_log

<Info>
  **ClickHouse Cloud에서 쿼리하기**

  이 시스템 테이블의 데이터는 ClickHouse Cloud의 각 노드에 로컬로 저장됩니다. 따라서 전체 데이터를 모두 확인하려면 `clusterAllReplicas` 함수를 사용해야 합니다. 자세한 내용은 [여기](/ko/reference/system-tables/overview#system-tables-in-clickhouse-cloud)를 참조하십시오.
</Info>

<div id="description">
  ## 설명
</div>

쿼리를 실행하는 스레드에 대한 정보가 포함됩니다. 예를 들어 스레드 이름, 스레드 시작 시간, 쿼리 처리 소요 시간 등이 있습니다.

로깅을 시작하려면:

1. [query\_thread\_log](/ko/reference/settings/server-settings/settings#query_thread_log) 섹션에서 매개변수를 설정합니다.
2. [log\_query\_threads](/ko/reference/settings/session-settings#log_query_threads)를 1로 설정합니다.

데이터 플러시 주기는 [query\_thread\_log](/ko/reference/settings/server-settings/settings#query_thread_log) 서버 설정 섹션의 `flush_interval_milliseconds` 매개변수에서 설정합니다. 강제로 플러시하려면 [SYSTEM FLUSH LOGS](/ko/reference/statements/system#flush-logs) 쿼리를 사용하십시오.

ClickHouse는 테이블에서 데이터를 자동으로 삭제하지 않습니다. 자세한 내용은 [Introduction](/ko/reference/system-tables/overview#system-tables-introduction)을 참조하십시오.

`query_thread_log` 테이블에 기록되는 쿼리 수를 줄이려면 [log\_queries\_probability](/ko/reference/settings/session-settings#log_queries_probability)) 설정을 사용할 수 있습니다.

<div id="columns">
  ## 컬럼
</div>

* `hostname` ([LowCardinality(String)](/ko/reference/data-types/lowcardinality)) — 쿼리를 실행한 서버의 호스트명입니다.
* `event_date` ([Date](/ko/reference/data-types/date)) — 스레드의 쿼리 실행이 완료된 날짜입니다.
* `event_time` ([DateTime](/ko/reference/data-types/datetime)) — 스레드의 쿼리 실행이 완료된 날짜 및 시간입니다.
* `event_time_microseconds` ([DateTime64(6)](/ko/reference/data-types/datetime64)) — 스레드가 쿼리 실행을 마친 시점의 날짜와 시간으로, 마이크로초 정밀도를 지원합니다.
* `query_start_time` ([DateTime](/ko/reference/data-types/datetime)) — 쿼리 실행이 시작된 시간입니다.
* `query_start_time_microseconds` ([DateTime64(6)](/ko/reference/data-types/datetime64)) — 마이크로초 단위 정밀도의 쿼리 실행 시작 시간입니다.
* `query_duration_ms` ([UInt64](/ko/reference/data-types/int-uint)) — 쿼리 실행에 걸린 시간입니다.
* `read_rows` ([UInt64](/ko/reference/data-types/int-uint)) — 읽은 행의 수입니다.
* `read_bytes` ([UInt64](/ko/reference/data-types/int-uint)) — 읽은 바이트 수입니다.
* `written_rows` ([UInt64](/ko/reference/data-types/int-uint)) — INSERT 쿼리의 경우 기록된 행 수입니다. 그 밖의 쿼리에서는 컬럼 값이 0입니다.
* `written_bytes` ([UInt64](/ko/reference/data-types/int-uint)) — INSERT 쿼리에서는 기록된 바이트 수를 나타냅니다. 다른 쿼리에서는 컬럼 값이 0입니다.
* `memory_usage` ([Int64](/ko/reference/data-types/int-uint)) — 이 스레드 컨텍스트에서 할당된 메모리 양과 해제된 메모리 양의 차이입니다.
* `peak_memory_usage` ([Int64](/ko/reference/data-types/int-uint)) — 이 스레드 컨텍스트에서 할당된 메모리 양과 해제된 메모리 양의 차이의 최댓값입니다.
* `thread_name` ([LowCardinality(String)](/ko/reference/data-types/lowcardinality)) — 스레드 이름.
* `thread_id` ([UInt64](/ko/reference/data-types/int-uint)) — 내부 스레드 ID.
* `master_thread_id` ([UInt64](/ko/reference/data-types/int-uint)) — 초기 스레드에 대한 OS 초기 ID.
* `current_database` ([LowCardinality(String)](/ko/reference/data-types/lowcardinality)) — 현재 데이터베이스 이름입니다.
* `query` ([String](/ko/reference/data-types/string)) — 쿼리 문자열.
* `normalized_query_hash` ([UInt64](/ko/reference/data-types/int-uint)) — 상수 등이 제거된 정규화된 쿼리의 해시입니다.
* `is_initial_query` ([UInt8](/ko/reference/data-types/int-uint)) — 쿼리 유형입니다. 가능한 값: 1 — 클라이언트가 시작한 쿼리, 0 — 분산 쿼리 실행을 위해 다른 쿼리에서 시작한 쿘리입니다.
* `connection_address` ([IPv6](/ko/reference/data-types/ipv6)) — 연결을 시작한 클라이언트의 IP 주소입니다. 프록시를 통해 연결한 경우 이 값은 프록시의 주소입니다.
* `connection_port` ([UInt16](/ko/reference/data-types/int-uint)) — 연결이 설정된 클라이언트의 포트입니다. 프록시를 통해 연결된 경우에는 프록시의 포트가 됩니다.
* `user` ([LowCardinality(String)](/ko/reference/data-types/lowcardinality)) — 현재 쿼리를 실행한 사용자의 이름입니다.
* `query_id` ([String](/ko/reference/data-types/string)) — 쿼리의 ID.
* `address` ([IPv6](/ko/reference/data-types/ipv6)) — 쿼리를 보낼 때 사용된 IP 주소입니다. 프록시를 통해 연결되어 있고 `auth_use_forwarded_address`가 설정된 경우, 이 값은 프록시 주소가 아니라 클라이언트 주소가 됩니다.
* `port` ([UInt16](/ko/reference/data-types/int-uint)) — 쿼리를 실행할 때 사용된 클라이언트 포트입니다. 프록시를 통해 연결되어 있고 `auth_use_forwarded_address`가 설정된 경우, 이 값은 프록시의 포트가 아니라 클라이언트의 포트입니다.
* `initial_user` ([LowCardinality(String)](/ko/reference/data-types/lowcardinality)) — 초기 쿼리(분산 쿼리 실행 시)를 실행한 사용자의 이름입니다.
* `initial_query_id` ([String](/ko/reference/data-types/string)) — 초기 쿼리의 ID입니다(분산 쿼리 실행 시 사용).
* `initial_address` ([IPv6](/ko/reference/data-types/ipv6)) — 상위 쿼리가 실행된 IP 주소입니다.
* `initial_port` ([UInt16](/ko/reference/data-types/int-uint)) — 상위 쿼리를 실행할 때 사용된 클라이언트 포트입니다.
* `initial_query_start_time` ([DateTime](/ko/reference/data-types/datetime)) — 초기 쿼리 실행 시작 시간입니다.
* `initial_query_start_time_microseconds` ([DateTime64(6)](/ko/reference/data-types/datetime64)) — 초기 쿼리 실행의 시작 시간
* `authenticated_user` ([LowCardinality(String)](/ko/reference/data-types/lowcardinality)) — 세션에서 인증된 사용자의 이름입니다.
* `interface` ([UInt8](/ko/reference/data-types/int-uint)) — 쿼리가 시작된 인터페이스입니다. 가능한 값: 1 — TCP, 2 — HTTP.
* `is_secure` ([UInt8](/ko/reference/data-types/int-uint)) — 연결이 보안되었는지 여부를 나타내는 플래그입니다.
* `os_user` ([LowCardinality(String)](/ko/reference/data-types/lowcardinality)) — OS에서 clickhouse-client를 실행하는 사용자의 이름입니다.
* `client_hostname` ([LowCardinality(String)](/ko/reference/data-types/lowcardinality)) — clickhouse-client 또는 다른 TCP 클라이언트가 실행되는 클라이언트 컴퓨터의 호스트명입니다.
* `client_name` ([LowCardinality(String)](/ko/reference/data-types/lowcardinality)) — `clickhouse-client` 또는 다른 TCP 클라이언트의 이름입니다.
* `client_revision` ([UInt32](/ko/reference/data-types/int-uint)) — clickhouse-client 또는 다른 TCP 클라이언트의 버전입니다.
* `client_version_major` ([UInt32](/ko/reference/data-types/int-uint)) — clickhouse-client 또는 다른 TCP 클라이언트의 주 버전입니다.
* `client_version_minor` ([UInt32](/ko/reference/data-types/int-uint)) — clickhouse-client 또는 다른 TCP 클라이언트의 마이너 버전입니다.
* `client_version_patch` ([UInt32](/ko/reference/data-types/int-uint)) — clickhouse-client 또는 다른 TCP 클라이언트 버전의 패치 버전입니다.
* `script_query_number` ([UInt32](/ko/reference/data-types/int-uint)) — 다중 쿼리 스크립트에서의 순차적 쿌리 번호입니다.
* `script_line_number` ([UInt32](/ko/reference/data-types/int-uint)) — 여러 쿼리로 구성된 스크립트에서 현재 쿼리가 시작되는 줄 번호입니다.
* `http_method` ([UInt8](/ko/reference/data-types/int-uint)) — 쿼리를 시작한 HTTP 메서드입니다. 가능한 값: 0 — 쿼리가 TCP 인터페이스에서 시작되었습니다., 1 — GET 메서드가 사용되었습니다., 2 — POST 메서드가 사용되었습니다.
* `http_user_agent` ([LowCardinality(String)](/ko/reference/data-types/lowcardinality)) — HTTP 요청과 함께 전달되는 UserAgent 헤더입니다.
* `http_referer` ([String](/ko/reference/data-types/string)) — HTTP 쿼리와 함께 전달되는 HTTP 헤더 `Referer`입니다(쿼리를 보내는 페이지의 전체 주소 또는 일부 주소를 포함합니다).
* `forwarded_for` ([String](/ko/reference/data-types/string)) — HTTP 쿼리에서 전달되는 HTTP 헤더 `X-Forwarded-For`.
* `quota_key` ([String](/ko/reference/data-types/string)) — 쿼터 설정에서 지정한 'quota key'입니다.
* `distributed_depth` ([UInt64](/ko/reference/data-types/int-uint)) — 쿼리가 서버 간에 몇 번 전달되었는지를 나타냅니다.
* `revision` ([UInt32](/ko/reference/data-types/int-uint)) — ClickHouse 리비전입니다.
* `ProfileEvents` ([Map(LowCardinality(String), UInt64)](/ko/reference/data-types/map)) — 이 스레드의 다양한 메트릭을 측정하는 ProfileEvents입니다. 이에 대한 설명은 system.events 테이블에서 확인할 수 있습니다.

**별칭:**

* `ProfileEvents.Names` — `mapKeys(ProfileEvents)`에 대한 별칭입니다.
* `ProfileEvents.Values` — `mapValues(ProfileEvents)`에 대한 별칭입니다.

<div id="example">
  ## 예시
</div>

```sql theme={null}
 SELECT * FROM system.query_thread_log LIMIT 1 \G
```

```text theme={null}
Row 1:
──────
hostname:                      clickhouse.eu-central1.internal
event_date:                    2020-09-11
event_time:                    2020-09-11 10:08:17
event_time_microseconds:       2020-09-11 10:08:17.134042
query_start_time:              2020-09-11 10:08:17
query_start_time_microseconds: 2020-09-11 10:08:17.063150
query_duration_ms:             70
read_rows:                     0
read_bytes:                    0
written_rows:                  1
written_bytes:                 12
memory_usage:                  4300844
peak_memory_usage:             4300844
thread_name:                   TCPHandler
thread_id:                     638133
master_thread_id:              638133
query:                         INSERT INTO test1 VALUES
is_initial_query:              1
user:                          default
query_id:                      50a320fd-85a8-49b8-8761-98a86bcbacef
address:                       ::ffff:127.0.0.1
port:                          33452
initial_user:                  default
initial_query_id:              50a320fd-85a8-49b8-8761-98a86bcbacef
initial_address:               ::ffff:127.0.0.1
initial_port:                  33452
interface:                     1
os_user:                       bharatnc
client_hostname:               tower
client_name:                   ClickHouse
client_revision:               54437
client_version_major:          20
client_version_minor:          7
client_version_patch:          2
http_method:                   0
http_user_agent:
quota_key:
revision:                      54440
ProfileEvents:        {'Query':1,'SelectQuery':1,'ReadCompressedBytes':36,'CompressedReadBufferBlocks':1,'CompressedReadBufferBytes':10,'IOBufferAllocs':1,'IOBufferAllocBytes':89,'ContextLock':15,'RWLockAcquiredReadLocks':1}
```

<div id="see-also">
  ## 관련 항목
</div>

* [system.query\_log](/ko/reference/system-tables/query_log) — 쿼리 실행과 관련된 일반적인 정보를 담고 있는 `query_log` 시스템 테이블에 대한 설명입니다.
* [system.query\_views\_log](/ko/reference/system-tables/query_views_log) — 이 테이블에는 쿼리 실행 중 각 뷰가 실행된 정보가 포함됩니다.
