Skip to content

Commit c9d88d2

Browse files
TCeasonsoyeric128
andauthored
system.query_log table add query_tag column (#1639)
* system.query_log table add query_tag column databendlabs/databend#17430 -- in session 1: set session query_tag=query-tag1; select xx from t; select * from system.query_log where query_tag=query-tag1; * add version and session tag example --------- Co-authored-by: Eric <[email protected]>
1 parent ee8b0fa commit c9d88d2

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

docs/en/sql-reference/00-sql-reference/20-system-tables/system-query-log.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,39 @@
22
title: system.query_log
33
---
44

5+
import FunctionDescription from '@site/src/components/FunctionDescription';
6+
7+
<FunctionDescription description="Introduced or updated: v1.2.696"/>
8+
59
A read-only in-memory table stores all the query logs.
610

711

12+
## Setting a Session Tag
13+
14+
You can optionally assign a tag to your session, making it easier to filter logs in the log table based on the assigned session tag. For example, the following assigns the tag ‘eric’ to the current session:
15+
16+
```sql
17+
set session query_tag='eric';
18+
19+
```
20+
21+
We can then run a query and retrieve the log from the log table using the assigned tag:
22+
23+
```sql
24+
show users;
25+
26+
select query_tag, query_text from system.query_log where query_tag='eric' limit 1;
27+
28+
```
29+
30+
In the returned result, you can find the record for the query, tagged as 'eric':
31+
32+
```sql
33+
-[ RECORD 1 ]-----------------------------------
34+
query_tag: eric
35+
query_text: SHOW USERS
36+
```
37+
838
## Examples
939

1040
```sql
@@ -20,6 +50,7 @@ SELECT * FROM system.query_log LIMIT 1;
2050
sql_user: root
2151
sql_user_quota: UserQuota<cpu:0,mem:0,store:0>
2252
sql_user_privileges: GRANT ALL ON *.*, ROLES: ["account_admin"]
53+
query_tag:
2354
query_id: 7e03cd7a-36fa-463d-afe4-041da4092c45
2455
query_kind: Other
2556
query_text: SHOW TABLES

0 commit comments

Comments
 (0)