Skip to content

Commit dbdeb23

Browse files
authored
Update system-query-log.md
1 parent 0200768 commit dbdeb23

File tree

1 file changed

+100
-18
lines changed

1 file changed

+100
-18
lines changed

docs/doc/30-reference/30-sql/70-system-tables/system-query-log.md

Lines changed: 100 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,71 @@
22
title: system.query_log
33
---
44

5-
A read-only in-memory table stores all the query logs;
5+
A read-only in-memory table stores all the query logs.
66

7-
```sql
8-
SELECT * FROM system.query_log ORDER BY event_time DESC LIMIT 1\G
9-
*************************** 1. row ***************************
7+
8+
## Columns
9+
10+
```
11+
CREATE TABLE `query_log` (
12+
`log_type` TINYINT,
13+
`handler_type` VARCHAR,
14+
`tenant_id` VARCHAR,
15+
`cluster_id` VARCHAR,
16+
`sql_user` VARCHAR,
17+
`sql_user_quota` VARCHAR,
18+
`sql_user_privileges` VARCHAR,
19+
`query_id` VARCHAR,
20+
`query_kind` VARCHAR,
21+
`query_text` VARCHAR,
22+
`event_date` DATE,
23+
`event_time` TIMESTAMP(3),
24+
`current_database` VARCHAR,
25+
`databases` VARCHAR,
26+
`tables` VARCHAR,
27+
`columns` VARCHAR,
28+
`projections` VARCHAR,
29+
`written_rows` BIGINT UNSIGNED,
30+
`written_bytes` BIGINT UNSIGNED,
31+
`written_io_bytes` BIGINT UNSIGNED,
32+
`written_io_bytes_cost_ms` BIGINT UNSIGNED,
33+
`scan_rows` BIGINT UNSIGNED,
34+
`scan_bytes` BIGINT UNSIGNED,
35+
`scan_io_bytes` BIGINT UNSIGNED,
36+
`scan_io_bytes_cost_ms` BIGINT UNSIGNED,
37+
`scan_partitions` BIGINT UNSIGNED,
38+
`total_partitions` BIGINT UNSIGNED,
39+
`result_rows` BIGINT UNSIGNED,
40+
`result_bytes` BIGINT UNSIGNED,
41+
`cpu_usage` INT UNSIGNED,
42+
`memory_usage` BIGINT UNSIGNED,
43+
`client_info` VARCHAR,
44+
`client_address` VARCHAR,
45+
`exception_code` INT,
46+
`exception_text` VARCHAR,
47+
`stack_trace` VARCHAR,
48+
`server_version` VARCHAR,
49+
`session_settings` VARCHAR,
50+
`extra` VARCHAR
51+
)
52+
```
53+
54+
## Examples
55+
56+
```
57+
*************************** 4. row ***************************
1058
log_type: 1
1159
handler_type: MySQL
12-
tenant_id: test_tenant
13-
cluster_id: test_cluster
60+
tenant_id: admin
61+
cluster_id:
1462
sql_user: root
1563
sql_user_quota: UserQuota<cpu:0,mem:0,store:0>
16-
sql_user_privileges: GRANT ALL ON *.* TO 'root'@'127.0.0.1', ROLES: []
17-
query_id: da879c17-94bb-4163-b2ac-ff4786bbe69e
18-
query_kind: SelectPlan
19-
query_text: SELECT * from system.query_log order by event_time desc limit 1
20-
event_date: 2022-03-24
21-
event_time: 2022-03-24 11:13:27.414
64+
sql_user_privileges: GRANT ALL ON *.*, ROLES: []
65+
query_id: eda2a82b-3667-4ffb-b436-953785178c39
66+
query_kind: Query
67+
query_text: select avg(number) from numbers(1000000)
68+
event_date: 2022-09-08
69+
event_time: 2022-09-08 03:32:39.517
2270
current_database: default
2371
databases:
2472
tables:
@@ -34,16 +82,50 @@ written_io_bytes_cost_ms: 0
3482
scan_io_bytes_cost_ms: 0
3583
scan_partitions: 0
3684
total_partitions: 0
37-
result_rows: 0
38-
result_bytes: 0
39-
cpu_usage: 10
40-
memory_usage: 1603
85+
86+
, skip_header=0, sql_dialect=PostgreSQL, storage_read_buffer_size=1048576, timezone=UTC, unquoted_ident_case_sensitive=0, wait_for_async_insert=1, wait_for_async_insert_timeout=100, scope: SESSION
87+
extra:
88+
89+
90+
*************************** 5. row ***************************
91+
log_type: 2
92+
handler_type: MySQL
93+
tenant_id: admin
94+
cluster_id:
95+
sql_user: root
96+
sql_user_quota: UserQuota<cpu:0,mem:0,store:0>
97+
sql_user_privileges: GRANT ALL ON *.*, ROLES: []
98+
query_id: eda2a82b-3667-4ffb-b436-953785178c39
99+
query_kind: Query
100+
query_text: select avg(number) from numbers(1000000)
101+
event_date: 2022-09-08
102+
event_time: 2022-09-08 03:32:39.519
103+
current_database: default
104+
databases:
105+
tables:
106+
columns:
107+
projections:
108+
written_rows: 0
109+
written_bytes: 0
110+
written_io_bytes: 0
111+
written_io_bytes_cost_ms: 0
112+
scan_rows: 1000000
113+
scan_bytes: 8000000
114+
scan_io_bytes: 0
115+
scan_io_bytes_cost_ms: 0
116+
scan_partitions: 0
117+
total_partitions: 0
118+
result_rows: 1
119+
result_bytes: 9
120+
cpu_usage: 24
121+
memory_usage: 0
41122
client_info:
42-
client_address: 127.0.0.1:56744
123+
client_address: 127.0.0.1:53304
43124
exception_code: 0
44125
exception_text:
45126
stack_trace:
46127
server_version:
47-
session_settings: enable_new_processor_framework=1, flight_client_timeout=60, max_block_size=10000, max_threads=8, storage_occ_backoff_init_delay_ms=5, storage_occ_backoff_max_delay_ms=20000, storage_occ_backoff_max_elapsed_ms=120000, storage_read_buffer_size=1048576, scope: SESSION
128+
session_settings: compression=None, empty_as_default=1, enable_async_insert=0, enable_new_processor_framework=1, enable_planner_v2=1, field_delimiter=,, flight_client_timeout=60, group_by_two_level_threshold=10000, max_block_size=10000, max_execute_time=0, max_threads=24, quoted_ident_case_sensitive=1, record_delimiter=
129+
, skip_header=0, sql_dialect=PostgreSQL, storage_read_buffer_size=1048576, timezone=UTC, unquoted_ident_case_sensitive=0, wait_for_async_insert=1, wait_for_async_insert_timeout=100, scope: SESSION
48130
extra:
49131
```

0 commit comments

Comments
 (0)