Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add the system.queries table #24992

Merged
merged 17 commits into from May 17, 2024
Merged

Conversation

hiltontj
Copy link
Contributor

@hiltontj hiltontj commented May 10, 2024

This PR is intended to follow #24990

This makes the system.queries table accessible. Accessing it is only possible when querying in debug mode, which is not currently enabled via the HTTP API, therefore this is only accessible via the gRPC interface, and the former will need to be enabled with a follow on PR (see #24989).

The system.queries table lists all queries in the QueryLog on the QueryExecutorImpl. Here is an example:

cargo run -p influxdb3 query -d foo "SELECT * FROM system.queries"
+--------------------------------------+---------+----------------------------+------------+------------------------------+------------+---------------+---------------+-----------------+------------------+------------------+------------------+------------+---------+---------+-----------+----------+
| id                                   | phase   | issue_time                 | query_type | query_text                   | partitions | parquet_files | plan_duration | permit_duration | execute_duration | end2end_duration | compute_duration | max_memory | success | running | cancelled | trace_id |
+--------------------------------------+---------+----------------------------+------------+------------------------------+------------+---------------+---------------+-----------------+------------------+------------------+------------------+------------+---------+---------+-----------+----------+
| 4d7aeaaa-3674-4195-9abd-fd2181356ab7 | success | 2024-05-14T14:48:33.811165 | sql        | SELECT * FROM cpu            | 0          | 0             | PT0.010397S   | PT0.000045S     | PT0.000666S      | PT0.011133S      | PT0.000040837S   | 0          | true    | false   | false     |          |
| f47aff2b-67ab-4d6b-8bb9-3790f428ed9a | fail    | 2024-05-14T14:48:40.027140 | sql        | SELECT * FROM pretty         |            |               | PT0.00035S    |                 |                  | PT0.000353S      |                  |            | false   | false   | false     |          |
| e3b6ed81-25b7-4dbd-b28d-9859d75b7eca | success | 2024-05-14T14:48:49.563634 | sql        | SELECT * FROM mem            | 0          | 0             | PT0.003124S   | PT0.000036S     | PT0.000338S      | PT0.003517S      | PT0.000007503S   | 1096       | true    | false   | false     |          |
| 38b49b03-7457-4dd9-9137-1ef7c3147bf6 | success | 2024-05-14T14:49:05.596032 | sql        | SELECT * FROM system.queries | 0          | 0             | PT0.00333S    | PT0.000044S     | PT0.000261S      | PT0.003641S      | P0D              | 0          | true    | false   | false     |          |
| 358b958e-abc8-46f8-b50f-d644f268ce9a | success | 2024-05-14T14:49:18.275394 | sql        | SELECT * FROM system.queries | 0          | 0             | PT0.00331S    | PT0.000045S     | PT0.000227S      | PT0.003589S      | P0D              | 0          | true    | false   | false     |          |
| dae91af0-c021-4053-a877-f6605fe358cc | success | 2024-05-14T14:49:41.603026 | sql        | SELECT * FROM system.queries | 0          | 0             | PT0.00294S    | PT0.000045S     | PT0.000215S      | PT0.003202S      | P0D              | 0          | true    | false   | false     |          |
+--------------------------------------+---------+----------------------------+------------+------------------------------+------------+---------------+---------------+-----------------+------------------+------------------+------------------+------------+---------+---------+-----------+----------+

Closes #24987

A shell for the `system` table provider was added to the QueryExecutorImpl
which currently does not do anything, but will enable us to tie the
different system table providers into it.

The QueryLog was elevated from the `Database`, i.e., namespace provider,
to the QueryExecutorImpl, so that it lives accross queries.
The system.queries table is now accessible, when queries are initiated
in debug mode, which is not currently enabled via the HTTP API, therefore
this is not yet accessible unless via the gRPC interface.

The system.queries table lists all queries in the QueryLog on the
QueryExecutorImpl.
@hiltontj hiltontj force-pushed the hiltontj/system-queries-table branch from 3ca0b29 to e3aa631 Compare May 13, 2024 20:41
}
}

fn queries_schema() -> SchemaRef {
Copy link
Contributor Author

@hiltontj hiltontj May 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function was mostly copied from IOx, we may trim down some of the columns, if they're not relevant, e.g., partitions.

@hiltontj hiltontj marked this pull request as ready for review May 13, 2024 20:48
@hiltontj hiltontj force-pushed the hiltontj/system-queries-table branch from b9044cd to c4430cf Compare May 16, 2024 13:23
Base automatically changed from hiltontj/system-tables to main May 17, 2024 15:21
@hiltontj hiltontj merged commit 0201feb into main May 17, 2024
12 checks passed
@hiltontj hiltontj deleted the hiltontj/system-queries-table branch May 17, 2024 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create the system.queries provider
2 participants