

 Amazon Redshift will no longer support the creation of new Python UDFs starting Patch 198. Existing Python UDFs will continue to function until June 30, 2026. For more information, see the [ blog post ](https://aws.amazon.com/blogs/big-data/amazon-redshift-python-user-defined-functions-will-reach-end-of-support-after-june-30-2026/). 

# SVL\_QLOG
<a name="r_SVL_QLOG"></a>

The SVL\_QLOG view contains a log of all queries run against the database.

Amazon Redshift creates the SVL\_QLOG view as a readable subset of information from the [STL\_QUERY](r_STL_QUERY.md) table. Use this table to find the query ID for a recently run query or to see how long it took a query to complete.

SVL\_QLOG is visible to all users. Superusers can see all rows; regular users can see only their own data. For more information, see [Visibility of data in system tables and views](cm_chap_system-tables.md#c_visibility-of-data).

Some or all of the data in this table can also be found in the SYS monitoring view [SYS\_QUERY\_HISTORY](SYS_QUERY_HISTORY.md). The data in the SYS monitoring view is formatted to be easier to use and understand. We recommend that you use the SYS monitoring view for your queries.

## Table columns
<a name="r_SVL_QLOG-table-columns"></a>


| Column name  | Data type  | Description  | 
| --- | --- | --- | 
| userid  | integer  | ID of the user who generated the entry.  | 
| query  | integer  | Query ID. You can use this ID to join various other system tables and views.  | 
| xid  | bigint  | Transaction ID.  | 
| pid  | integer  | Process ID associated with the query.  | 
| starttime  | timestamp | Exact time when the statement started executing, with six digits of precision for fractional seconds—for example: 2009-06-12 11:29:19.131358  | 
| endtime  | timestamp | Exact time when the statement finished executing, with six digits of precision for fractional seconds—for example: 2009-06-12 11:29:19.193640  | 
| elapsed  | bigint  | Length of time that it took the query to run (in microseconds).  | 
| aborted  | integer  | If a query was stopped by the system or canceled by the user, this column contains 1. If the query ran to completion, this column contains 0. Queries that are canceled for workload management purposes and subsequently restarted also have a value of 1 in this column.  | 
| label  | character(320)  | Either the name of the file used to run the query, or a label defined with a SET QUERY\_GROUP command. If the query is not file-based or the QUERY\_GROUP parameter is not set, this field value is default.  | 
| substring | character(60)  | Truncated query text.  | 
| source\_query | integer | If the query used result caching, the query ID of the query that was the source of the cached results. If result caching was not used, this field value is NULL.  | 
| concurrency\_scaling\_status\_txt | text | A description of whether the query ran on the main cluster or concurrency scaling cluster.  | 
| from\_sp\_call | integer | If the query was called from a stored procedure, the query ID of the procedure call. If the query wasn't run as part of a stored procedure, this field is NULL.  | 

## Sample queries
<a name="r_SVL_QLOG-sample-queries"></a>

The following example returns the query ID, execution time, and truncated query text for the five most recent database queries run by the user with `userid = 100`.

```
select query, pid, elapsed, substring from svl_qlog
where userid = 100
order by starttime desc
limit 5;

 query  |  pid  | elapsed  |           substring
--------+-------+----------+-----------------------------------------------
 187752 | 18921 | 18465685 | select query, elapsed, substring from svl_...
 204168 |  5117 |    59603 | insert into testtable values (100);
 187561 | 17046 |  1003052 | select * from pg_table_def where tablename...
 187549 | 17046 |  1108584 | select * from STV_WLM_SERVICE_CLASS_CONFIG
 187468 | 17046 |  5670661 | select * from pg_table_def where schemaname...
(5 rows)
```

The following example returns the SQL script name (LABEL column) and elapsed time for a query that was cancelled (**aborted=1**): 

```
select query, elapsed, trim(label) querylabel
from svl_qlog where aborted=1;
 
 query | elapsed  |       querylabel
-------+----------+-------------------------
    16 |  6935292 | alltickittablesjoin.sql
(1 row)
```