Information schema for engine query history
You can use the information_schema.engine_query_history
view to return information about queries saved to query history. The view is available in each database and contains two rows (start and finish) for each historical query in the database. The table is limited to contain the last 10’000 queries per engine cluster. You can use a SELECT
query to return information about each query as shown in the example below.
SELECT
*
FROM
information_schema.engine_query_history
LIMIT
100;
Columns in information_schema.engine_query_history
Each row has the following columns with information about each query in query history.
Column Name | Data Type | Description |
---|---|---|
account_name | TEXT | The name of the account in which the query was executed. |
user_name | TEXT | The user name that was used to execute the query. (present for account level operations otherwise NULL for org level ones). |
login_name | TEXT | The login name that was used to execute the query (present for org level statements otherwise NULL). |
service_account_name | TEXT | The service account name that was used to execute the query (present for org level statements otherwise NULL). |
submitted_time | TIMESTAMPTZ | The time that the query was submitted by the user. |
start_time | TIMESTAMPTZ | The query execution start time (UTC). |
end_time | TIMESTAMPTZ | The query execution end time (UTC). |
duration_us | BIGINT | The duration of query run time (microseconds). |
status | TEXT | Can be one of the following values:STARTED_EXECUTION –Successful start of query execution.ENDED_SUCCESSFULLY –Successful end of query execution.CANCELED_EXECUTION –Query was canceledPARSE_ERROR –Query could not be parsedEXECUTION_ERROR –Query could not be executed successfully |
request_id | TEXT | The ID of the request from which the query originates. |
query_id | TEXT | The unique identifier of the SQL query. |
query_label | TEXT | A user-provided query label (query_label parameter) |
query_text | TEXT | The text of the SQL statement. |
query_text_normalized | TEXT | The normalized text of the SQL statement. |
query_text_normalized_hash | TEXT | The hash of the normalized text of the SQL statement. |
error_message | TEXT | The returned error message. |
scanned_rows | BIGINT | The total number of rows scanned. |
scanned_bytes | BIGINT | The total number of bytes scanned (both from cache and storage). |
inserted_rows | BIGINT | The total number of rows written. |
inserted_bytes | BIGINT | The total number of bytes written (to both cache and storage). |
spilled_bytes | BIGINT | The total number of uncompressed bytes spilled. |
total_ram_consumed | BIGINT | The total number of engine bytes in RAM consumed during query run time. |
returned_rows | BIGINT | The total number of rows returned from the query. |
returned_bytes | BIGINT | The total number of bytes returned from the query. |
time_in_queue_us | BIGINT | The number of microseconds the query spent in queue. |
retries | BIGINT | The total number of retries to run a given query after a failure. By default, the number of retries is 0, and the number increases with each retry. |