

 从补丁 198 开始，Amazon Redshift 将不再支持创建新的 Python UDF。现有的 Python UDF 将继续正常运行至 2026 年 6 月 30 日。有关更多信息，请参阅[博客文章](https://www.amazonaws.cn/blogs/big-data/amazon-redshift-python-user-defined-functions-will-reach-end-of-support-after-june-30-2026/)。

# SVL\$1QLOG
<a name="r_SVL_QLOG"></a>

SVL\$1QLOG 视图包含针对数据库运行的所有查询的日志。

Amazon Redshift 创建 SVL\$1QLOG 视图作为 [STL\$1QUERY](r_STL_QUERY.md) 表中信息的可读子集。使用该表可找出最近运行的查询的查询 ID，或查看完成某项查询用了多长时间。

SVL\$1QLOG 对所有用户可见。超级用户可以查看所有行；普通用户只能查看其自己的数据。有关更多信息，请参阅 [系统表和视图中的数据可见性](cm_chap_system-tables.md#c_visibility-of-data)。

此表中的部分或全部数据也可以在 SYS 监控视图 [SYS\$1QUERY\$1HISTORY](SYS_QUERY_HISTORY.md) 中找到。SYS 监控视图中的数据经过格式化处理，便于使用和理解。我们建议您使用 SYS 监控视图进行查询。

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

[\[See the AWS documentation website for more details\]](http://docs.amazonaws.cn/redshift/latest/dg/r_SVL_QLOG.html)

## 示例查询
<a name="r_SVL_QLOG-sample-queries"></a>

下面的示例返回 `userid = 100` 的用户最近运行的五个数据库查询的查询 ID、执行时间和截断的查询文本。

```
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)
```

下面的示例返回已取消的查询 (**aborted=1**) 的 SQL 脚本名称（LABEL 列）和已用时间：

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