@@ -5,8 +5,9 @@ You can query the system tables for information about your running server, datab
5
5
## Query system tables
6
6
7
7
- [ Use the HTTP query API] ( #use-the-http-query-api )
8
- - [ Example: show tables] ( #example-show-tables )
9
- - [ Example: view column information for a table] ( #example-view-column-information-for-a-table )
8
+ - [ Examples] ( #examples )
9
+ - [ Show tables] ( #show-tables )
10
+ - [ View column information for a table] ( #view-column-information-for-a-table )
10
11
11
12
### Use the HTTP query API
12
13
@@ -32,7 +33,18 @@ Include the following parameters:
32
33
JSONL (` jsonl ` ) is preferred because it streams results back to the client.
33
34
` pretty ` is for human-readable output. Default is ` json ` .
34
35
35
- #### Example: show tables
36
+ #### Examples
37
+
38
+ > [ !Note]
39
+ > #### system_ sample data
40
+ >
41
+ > In examples, tables with ` "table_name":"system_ ` are user-created tables for CPU, memory, disk,
42
+ > network, and other resource statistics collected and written
43
+ > by the user--for example, using the ` psutil ` Python library or
44
+ > [ Telegraf] ( https://docs.influxdata.com/telegraf/v1/get-started/ ) to collect
45
+ > and write system metrics to an InfluxDB 3 database.
46
+
47
+ ##### Show tables
36
48
37
49
The following example sends a ` GET ` request that executes a ` show tables ` query
38
50
to retrieve all user-created
@@ -76,7 +88,7 @@ A table has one of the following `table_schema` values:
76
88
while others, such as the ` queries ` table, hold ephemeral state in memory.
77
89
- ` information_schema ` : views that show schema information for tables in the database.
78
90
79
- #### Example: view column information for a table
91
+ #### View column information for a table
80
92
81
93
The following query sends a ` POST ` request that executes an SQL query to
82
94
retrieve information about columns in the sample ` system_swap ` table schema:
@@ -88,7 +100,7 @@ that surround field names._
88
100
curl " http://localhost:8181/api/v3/query_sql" \
89
101
--header " Content-Type: application/json" \
90
102
--json ' {
91
- "db": "cpu ",
103
+ "db": "mydb ",
92
104
"q": "SELECT * FROM information_schema.columns WHERE table_schema = ' " 'iox'" ' AND table_name = ' " 'system_swap'" ' ",
93
105
"format": "jsonl"
94
106
}'
@@ -107,12 +119,22 @@ The output is the following:
107
119
{"table_catalog" :" public" ,"table_schema" :" iox" ,"table_name" :" system_swap" ,"column_name" :" used" ,"ordinal_position" :7 ,"is_nullable" :" YES" ,"data_type" :" UInt64" }
108
120
```
109
121
122
+ #### Recently executed queries
123
+
110
124
To view recently executed queries, query the ` queries ` system table:
111
125
112
- ``` SQL
113
- SELECT * FROM system .queries LIMIT 2
126
+ ``` bash
127
+ curl " http://localhost:8181/api/v3/query_sql" \
128
+ --header " Content-Type: application/json" \
129
+ --json ' {
130
+ "db": "mydb",
131
+ "q": "SELECT * FROM system.queries LIMIT 2",
132
+ "format": "jsonl"
133
+ }'
114
134
```
115
135
136
+ The output is the following:
137
+
116
138
``` jsonl
117
139
{"id" :" cdd63409-1822-4e65-8e3a-d274d553dbb3" ,"phase" :" success" ,"issue_time" :" 2025-01-20T17:01:40.690067" ,"query_type" :" sql" ,"query_text" :" show tables" ,"partitions" :0 ,"parquet_files" :0 ,"plan_duration" :" PT0.032689S" ,"permit_duration" :" PT0.000202S" ,"execute_duration" :" PT0.000223S" ,"end2end_duration" :" PT0.033115S" ,"compute_duration" :" P0D" ,"max_memory" :0 ,"success" :true ,"running" :false ,"cancelled" :false }
118
140
{"id" :" 47f8d312-5e75-4db2-837a-6fcf94c09927" ,"phase" :" success" ,"issue_time" :" 2025-01-20T17:02:32.627782" ,"query_type" :" sql" ,"query_text" :" show tables" ,"partitions" :0 ,"parquet_files" :0 ,"plan_duration" :" PT0.000583S" ,"permit_duration" :" PT0.000015S" ,"execute_duration" :" PT0.000063S" ,"end2end_duration" :" PT0.000662S" ,"compute_duration" :" P0D" ,"max_memory" :0 ,"success" :true ,"running" :false ,"cancelled" :false }
0 commit comments