Skip to content

Commit a78464f

Browse files
authored
Merge pull request #609 from erizocosmico/docs/show-processlist
docs: add example of how to use show processlist
2 parents 19800be + 5786827 commit a78464f

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

docs/using-gitbase/examples.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,3 +202,41 @@ The UDF `uast_children` will return a flattened array of the children nodes from
202202
```sql
203203
SELECT file_path, uast_children(uast(blob_content, language(file_path), "//uast:Alias")) FROM files;
204204
```
205+
206+
## Monitor the progress of a query
207+
208+
You can monitor the progress of a gitbase query (either a regular query or an index creation query using `SHOW PROCESSLIST`).
209+
210+
Let's say we do the following query over a huge repository:
211+
212+
```sql
213+
SELECT language(file_path, blob_content) FROM files
214+
```
215+
216+
With this query we can monitor its progress:
217+
218+
```sql
219+
SHOW PROCESSLIST
220+
```
221+
222+
We'll get the following output:
223+
224+
```
225+
+------+------+----------------+---------+---------+------+------------+-----------------------------------------------------+
226+
| Id | User | Host | db | Command | Time | State | Info |
227+
+------+------+----------------+---------+---------+------+------------+-----------------------------------------------------+
228+
| 2 | root | 127.0.0.1:3306 | gitbase | query | 36 | files(1/3) | select language(file_path, blob_content) from files |
229+
| 12 | root | 127.0.0.1:3306 | gitbase | query | 0 | running | show processlist |
230+
+------+------+----------------+---------+---------+------+------------+-----------------------------------------------------+
231+
2 rows in set (0,00 sec)
232+
```
233+
234+
From this output, we can obtain some information about our query:
235+
- It's been running for 36 seconds.
236+
- It's only querying files table and has processed 1 out of 3 partitions.
237+
238+
To kill a query that's currently running you can use the value in `Id`. If we were to kill the previous query, we would need to use the following query:
239+
240+
```sql
241+
KILL QUERY 2
242+
```

0 commit comments

Comments
 (0)