

 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/). 

# SYS monitoring views
<a name="serverless_views-monitoring"></a>

*Monitoring views* are system views in Amazon Redshift that are used to monitor query and workload resource usage of provisioned clusters and serverless workgroups. These views are located in the `pg_catalog` schema. To display the information provided by these views, run SQL SELECT statements.

Unless noted otherwise, these views are available for Amazon Redshift clusters and Amazon Redshift Serverless workgroups.

*SYS\$1SERVERLESS\$1USAGE* gathers usage data for Amazon Redshift Serverless only.

**Topics**
+ [

# SYS\$1ANALYZE\$1COMPRESSION\$1HISTORY
](r_SYS_ANALYZE_COMPRESSION_HISTORY.md)
+ [

# SYS\$1ANALYZE\$1HISTORY
](SYS_ANALYZE_HISTORY.md)
+ [

# SYS\$1APPLIED\$1MASKING\$1POLICY\$1LOG
](SYS_APPLIED_MASKING_POLICY_LOG.md)
+ [

# SYS\$1AUTOMATIC\$1OPTIMIZATION
](SYS_AUTOMATIC_OPTIMIZATION.md)
+ [

# SYS\$1AUTO\$1TABLE\$1OPTIMIZATION
](r_SYS_AUTO_TABLE_OPTIMIZATION.md)
+ [

# SYS\$1CHILD\$1QUERY\$1TEXT
](SYS_CHILD_QUERY_TEXT.md)
+ [

# SYS\$1CONNECTION\$1LOG
](SYS_CONNECTION_LOG.md)
+ [

# SYS\$1COPY\$1JOB
](SYS_COPY_JOB.md)
+ [

# SYS\$1COPY\$1JOB\$1DETAIL
](SYS_COPY_JOB_DETAIL.md)
+ [

# SYS\$1COPY\$1JOB\$1INFO
](SYS_COPY_JOB_INFO.md)
+ [

# SYS\$1COPY\$1REPLACEMENTS
](SYS_COPY_REPLACEMENTS.md)
+ [

# SYS\$1DATASHARE\$1CHANGE\$1LOG
](SYS_DATASHARE_CHANGE_LOG.md)
+ [

# SYS\$1DATASHARE\$1CROSS\$1REGION\$1USAGE
](r_SYS_DATASHARE_CROSS_REGION_USAGE.md)
+ [

# SYS\$1DATASHARE\$1USAGE\$1CONSUMER
](SYS_DATASHARE_USAGE_CONSUMER.md)
+ [

# SYS\$1DATASHARE\$1USAGE\$1PRODUCER
](SYS_DATASHARE_USAGE_PRODUCER.md)
+ [

# SYS\$1EXTERNAL\$1QUERY\$1DETAIL
](SYS_EXTERNAL_QUERY_DETAIL.md)
+ [

# SYS\$1EXTERNAL\$1QUERY\$1ERROR
](SYS_EXTERNAL_QUERY_ERROR.md)
+ [

# SYS\$1EXTRA\$1COMPUTE\$1FOR\$1AUTOMATIC\$1OPTIMIZATION
](SYS_EXTRA_COMPUTE_FOR_AUTOMATIC_OPTIMIZATION.md)
+ [

# SYS\$1INTEGRATION\$1ACTIVITY
](r_SYS_INTEGRATION_ACTIVITY.md)
+ [

# SYS\$1INTEGRATION\$1TABLE\$1ACTIVITY
](r_SYS_INTEGRATION_TABLE_ACTIVITY.md)
+ [

# SYS\$1INTEGRATION\$1TABLE\$1STATE\$1CHANGE
](r_SYS_INTEGRATION_TABLE_STATE_CHANGE.md)
+ [

# SYS\$1LOAD\$1DETAIL
](SYS_LOAD_DETAIL.md)
+ [

# SYS\$1LUDF\$1DETAIL
](SYS_LUDF_DETAIL.md)
+ [

# SYS\$1LOAD\$1ERROR\$1DETAIL
](SYS_LOAD_ERROR_DETAIL.md)
+ [

# SYS\$1LOAD\$1HISTORY
](SYS_LOAD_HISTORY.md)
+ [

# SYS\$1MV\$1REFRESH\$1HISTORY
](SYS_MV_REFRESH_HISTORY.md)
+ [

# SYS\$1MV\$1STATE
](SYS_MV_STATE.md)
+ [

# SYS\$1PROCEDURE\$1CALL
](SYS_PROCEDURE_CALL.md)
+ [

# SYS\$1PROCEDURE\$1MESSAGES
](SYS_PROCEDURE_MESSAGES.md)
+ [

# SYS\$1QUERY\$1DETAIL
](SYS_QUERY_DETAIL.md)
+ [

# SYS\$1QUERY\$1EXPLAIN
](SYS_QUERY_EXPLAIN.md)
+ [

# SYS\$1QUERY\$1HISTORY
](SYS_QUERY_HISTORY.md)
+ [

# SYS\$1QUERY\$1TEXT
](SYS_QUERY_TEXT.md)
+ [

# SYS\$1REDSHIFT\$1TEMPLATE
](SYS_REDSHIFT_TEMPLATE.md)
+ [

# SYS\$1RESTORE\$1LOG
](SYS_RESTORE_LOG.md)
+ [

# SYS\$1RESTORE\$1STATE
](SYS_RESTORE_STATE.md)
+ [

# SYS\$1SCHEMA\$1QUOTA\$1VIOLATIONS
](r_SYS_SCHEMA_QUOTA_VIOLATIONS.md)
+ [

# SYS\$1SERVERLESS\$1USAGE
](SYS_SERVERLESS_USAGE.md)
+ [

# SYS\$1SESSION\$1HISTORY
](SYS_SESSION_HISTORY.md)
+ [

# SYS\$1SPATIAL\$1SIMPLIFY
](SYS_SPATIAL_SIMPLIFY.md)
+ [

# SYS\$1STREAM\$1SCAN\$1ERRORS
](r_SYS_STREAM_SCAN_ERRORS.md)
+ [

# SYS\$1STREAM\$1SCAN\$1STATES
](r_SYS_STREAM_SCAN_STATES.md)
+ [

# SYS\$1TRANSACTION\$1HISTORY
](SYS_TRANSACTION_HISTORY.md)
+ [

# SYS\$1UDF\$1LOG
](SYS_UDF_LOG.md)
+ [

# SYS\$1UNLOAD\$1DETAIL
](SYS_UNLOAD_DETAIL.md)
+ [

# SYS\$1UNLOAD\$1HISTORY
](SYS_UNLOAD_HISTORY.md)
+ [

# SYS\$1USERLOG
](SYS_USERLOG.md)
+ [

# SYS\$1VACUUM\$1HISTORY
](SYS_VACUUM_HISTORY.md)

# SYS\$1ANALYZE\$1COMPRESSION\$1HISTORY
<a name="r_SYS_ANALYZE_COMPRESSION_HISTORY"></a>

Records details for compression analysis operations during COPY or ANALYZE COMPRESSION commands.

SYS\$1ANALYZE\$1COMPRESSION\$1HISTORY 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).

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

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/redshift/latest/dg/r_SYS_ANALYZE_COMPRESSION_HISTORY.html)

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

The following example inspects the details of compression analysis on the `lineitem` table by the last COPY command run in the same session. 

```
select transaction_id, table_id, btrim(table_name) as table_name, column_position, old_encoding, new_encoding, mode 
from sys_analyze_compression_history
where transaction_id = (select transaction_id from sys_query_history where query_id = pg_last_copy_id()) order by column_position;
                
 transaction_id  |  table_id   | table_name | column_position |  old_encoding   |  new_encoding   |      mode
-----------------+-------------+------------+-----------------+-----------------+-----------------+-------------
      8196       |   248126    | lineitem   |        0        | mostly32        | mostly32        | ON
      8196       |   248126    | lineitem   |        1        | mostly32        | lzo             | ON
      8196       |   248126    | lineitem   |        2        | lzo             | delta32k        | ON
      8196       |   248126    | lineitem   |        3        | delta           | delta           | ON
      8196       |   248126    | lineitem   |        4        | bytedict        | bytedict        | ON
      8196       |   248126    | lineitem   |        5        | mostly32        | mostly32        | ON
      8196       |   248126    | lineitem   |        6        | delta           | delta           | ON
      8196       |   248126    | lineitem   |        7        | delta           | delta           | ON
      8196       |   248126    | lineitem   |        8        | lzo             | zstd            | ON
      8196       |   248126    | lineitem   |        9        | runlength       | zstd            | ON
      8196       |   248126    | lineitem   |       10        | delta           | lzo             | ON
      8196       |   248126    | lineitem   |       11        | delta           | delta           | ON
      8196       |   248126    | lineitem   |       12        | delta           | delta           | ON
      8196       |   248126    | lineitem   |       13        | bytedict        | zstd            | ON
      8196       |   248126    | lineitem   |       14        | bytedict        | zstd            | ON
      8196       |   248126    | lineitem   |       15        | text255         | zstd            | ON
(16 rows)
```

# SYS\$1ANALYZE\$1HISTORY
<a name="SYS_ANALYZE_HISTORY"></a>

Logs details for [ANALYZE](https://docs.aws.amazon.com/redshift/latest/dg/r_ANALYZE.html) operations.

SYS\$1ANALYZE\$1HISTORY is visible only to superusers. For more information, see [Visibility of data in system tables and views](cm_chap_system-tables.md#c_visibility-of-data).

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

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/redshift/latest/dg/SYS_ANALYZE_HISTORY.html)

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

```
 user_id | transaction_id | database_name | schema_name |      table_name     | table_id | is_automatic | Status |         start_time         |          end_time          | rows | modified_rows | analyze_threshold_percent |  last_analyze_time  
---------+----------------+---------------+-------------+---------------------+----------+--------------+--------+----------------------------+----------+-----------------+------+---------------+---------------------------+---------------------
     101 |           8006 |           dev |      public | test_table_562bf8dc |   110427 |            f |   Full | 2023-09-21 18:33:08.504646 | 2023-09-21 18:33:24.296498 |    5 |             5 |                         0 | 2000-01-01 00:00:00
```

# SYS\$1APPLIED\$1MASKING\$1POLICY\$1LOG
<a name="SYS_APPLIED_MASKING_POLICY_LOG"></a>

Use SYS\$1APPLIED\$1MASKING\$1POLICY\$1LOG to trace the application of dynamic data masking policies on queries that reference DDM-protected relations.

SYS\$1APPLIED\$1MASKING\$1POLICY\$1LOG is visible to the following users:
+  Superusers 
+  Users with the `sys:operator` role 
+  Users with the ACCESS SYSTEM TABLE permission 

Regular users will see 0 rows.

Note that SYS\$1APPLIED\$1MASKING\$1POLICY\$1LOG isn’t visible to users with the `sys:secadmin` role.

For more information on dynamic data masking, go to [Dynamic data masking](t_ddm.md).

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

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/redshift/latest/dg/SYS_APPLIED_MASKING_POLICY_LOG.html)

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

The following example shows that the `mask_credit_card_full` masking policy is attached to the `credit_db.public.credit_cards` table.

```
select policy_name, database_name, relation_name, schema_name, relation_kind 
from sys_applied_masking_policy_log;

policy_name           | database_name | relation_name | schema_name | relation_kind
----------------------+---------------+---------------+-------------+---------------
mask_credit_card_full | credit_db     | credit_cards  | public      | table

(1 row)
```

# SYS\$1AUTOMATIC\$1OPTIMIZATION
<a name="SYS_AUTOMATIC_OPTIMIZATION"></a>

Use SYS\$1AUTOMATIC\$1OPTIMIZATION to view details on the tasks that Amazon Redshift runs for automatic optimization, also known as autonomics. For more information on automatic optimization, see [Automatic database optimization](c_autonomics.md).

SYS\$1AUTOMATIC\$1OPTIMIZATION is visible only to superusers. For more information, see [Visibility of data in system tables and views](cm_chap_system-tables.md#c_visibility-of-data).

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

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/redshift/latest/dg/SYS_AUTOMATIC_OPTIMIZATION.html)

## Usage notes
<a name="SYS_AUTOMATIC_OPTIMIZATION-usage-notes"></a>

The compute\$1type column will be empty for serverless clusters because we do not differentiate primary or primary-scale compute resources. Serverless cluster compute resources are measured by Redshift Processing Units (RPUs) usage. For more information, see [Compute capacity for Amazon Redshift Serverless](https://docs.aws.amazon.com/redshift/latest/mgmt/serverless-capacity.html).

## Examples
<a name="SYS_AUTOMATIC_OPTIMIZATION-examples"></a>

The following query displays the automatic optimizations performed on table 155259.

```
SELECT pid, trim(task_type) as task_type,
  trim(database) as database,
  trim(status) as status,
  trim(event) as event,
  event_time
from SYS_AUTOMATIC_OPTIMIZATION
WHERE object_ids like '%155259%'
AND status = 'Task completed successfully';

 task_type  |    database    |           status            |   event   |         event_time
------------+----------------+-----------------------------+-----------+----------------------------
 VacuumSort | tpcds_100g_oob | Task completed successfully | Completed | 2025-12-22 07:27:15.943018
```

The following query shows all executed automatic "VacuumSort" optimizations. For more information about "VacuumSort", see [Automatic table sort](t_Reclaiming_storage_space202.md#automatic-table-sort).

```
SELECT trim(task_type) as task_type,
  trim(database) as database,
  trim(object_type) as object_type,
  trim(object_ids) as object_ids,
  trim(status) as status,
  trim(event) as event,
  event_time
from SYS_AUTOMATIC_OPTIMIZATION
WHERE task_type like '%VacuumSort%'
AND status = 'Task completed successfully';

task_type  |    database    | object_type | object_ids |           status            |   event   |         event_time
------------+----------------+-------------+------------+-----------------------------+-----------+----------------------------
 VacuumSort | tpcds_100g_oob | table       | 155301     | Task completed successfully | Completed | 2025-12-22 07:14:00.065391
 VacuumSort | tpcds_100g_oob | table       | 155303     | Task completed successfully | Completed | 2025-12-22 07:14:09.158251
 VacuumSort | tpcds_100g_oob | table       | 155291     | Task completed successfully | Completed | 2025-12-22 07:17:06.61164
 VacuumSort | tpcds_100g_oob | table       | 155293     | Task completed successfully | Completed | 2025-12-22 07:17:37.015069
 VacuumSort | tpcds_100g_oob | table       | 155281     | Task completed successfully | Completed | 2025-12-22 07:18:54.903935
 VacuumSort | tpcds_100g_oob | table       | 155279     | Task completed successfully | Completed | 2025-12-22 07:20:13.960002
 VacuumSort | tpcds_100g_oob | table       | 155271     | Task completed successfully | Completed | 2025-12-22 07:21:26.095549
 VacuumSort | tpcds_100g_oob | table       | 155267     | Task completed successfully | Completed | 2025-12-22 07:22:48.119249
 VacuumSort | tpcds_100g_oob | table       | 155269     | Task completed successfully | Completed | 2025-12-22 07:24:12.010424
 VacuumSort | tpcds_100g_oob | table       | 155263     | Task completed successfully | Completed | 2025-12-22 07:25:35.958388
 VacuumSort | tpcds_100g_oob | table       | 155265     | Task completed successfully | Completed | 2025-12-22 07:26:40.580395
 VacuumSort | tpcds_100g_oob | table       | 155259     | Task completed successfully | Completed | 2025-12-22 07:27:15.943018
(12 rows)
```

# SYS\$1AUTO\$1TABLE\$1OPTIMIZATION
<a name="r_SYS_AUTO_TABLE_OPTIMIZATION"></a>

Records automated actions taken by Amazon Redshift on tables defined for automatic optimization. 

SYS\$1AUTO\$1TABLE\$1OPTIMIZATION is visible only to superusers. For more information, see [Visibility of data in system tables and views](cm_chap_system-tables.md#c_visibility-of-data).

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

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/redshift/latest/dg/r_SYS_AUTO_TABLE_OPTIMIZATION.html)

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

In the following example, the rows in the result show actions taken by Amazon Redshift. 

```
SELECT table_id, alter_table_type, status, event_time, alter_from
FROM SYS_AUTO_TABLE_OPTIMIZATION;
                
 table_id |  alter_table_type   |                        status                        |         event_time          |  alter_from
----------+---------------------+------------------------------------------------------+-----------------------------+-----------------
   118082 | sortkey             | Start                                                | 2020-08-22 19:42:20.727049  | 
   118078 | sortkey             | Start                                                | 2020-08-22 19:43:54.728819  | 
   118082 | sortkey             | Start                                                | 2020-08-22 19:42:52.690264  | 
   118072 | sortkey             | Start                                                | 2020-08-22 19:44:14.793572  | 
   118082 | sortkey             | Failed                                               | 2020-08-22 19:42:20.728917  | 
   118078 | sortkey             | Complete                                             | 2020-08-22 19:43:54.792705  |  SORTKEY: None;
   118086 | sortkey             | Complete                                             | 2020-08-22 19:42:00.72635   |  SORTKEY: None;
   118082 | sortkey             | Complete                                             | 2020-08-22 19:43:34.728144  |  SORTKEY: None;
   118072 | sortkey             | Skipped:Retry exceeds the maximum limit for a table. | 2020-08-22 19:44:46.706155  | 
   118086 | sortkey             | Start                                                | 2020-08-22 19:42:00.685255  | 
   118082 | sortkey             | Start                                                | 2020-08-22 19:43:34.69531   | 
   118072 | sortkey             | Start                                                | 2020-08-22 19:44:46.703331  | 
   118082 | sortkey             | Checkpoint: progress 14.755079%                      | 2020-08-22 19:42:52.692828  | 
   118072 | sortkey             | Failed                                               | 2020-08-22 19:44:14.796071  |   
   116723 | sortkey             | Abort:This table is not AUTO.                        | 2020-10-28 05:12:58.479233  | 
   110203 | distkey             | Abort:This table is not AUTO.                        | 2020-10-28 05:45:54.67259   |
```

# SYS\$1CHILD\$1QUERY\$1TEXT
<a name="SYS_CHILD_QUERY_TEXT"></a>

Returns the SQL text of a child query.

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

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/redshift/latest/dg/SYS_CHILD_QUERY_TEXT.html)

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

In the following example, the rows in the result show actions taken by Amazon Redshift. 

```
SELECT * from sys_child_query_text where query_id = '34487366' order by child_query_sequence asc, sequence asc;
                
user_id | query_id | child_query_sequence | sequence | text
--------|----------|----------------------|----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
100     | 34899339 |   1                  |    0     |  /* RQEV2-aY6ZZ1ZpQK */\nwith venue as (\n    select venueid,\n            venuename,\n            venuestate\n    from venue\n), event as (\n    select eventid,\n            venueid,\n            date    
100     | 34899339 |   1                  |    1     |  id,\n            eventname\n    from event\n    where eventname like '3 Doors Down'\n), users as (\n    select userid\n    from users\n), sales as (\n    select salesid,\n            pricepaid,           
100     | 34899339 |   1                  |    2     |  \n            eventid,\n            buyerid\n    from sales\n)\nselect e.eventname,\n        v.venuename,\n        count(distinct(u.userid)) as unique_customers,\n        sum(s.pricepaid) as total_sal    
100     | 34899339 |   1                  |    3     |  es\nfrom venue as v inner join event e on v.venueid = e.venueid\ninner join sales s on e.eventid = s.eventid inner join users u on s.buyerid = u.userid\ngroup by 1,2\norder by 4 desc limit 100
```

# SYS\$1CONNECTION\$1LOG
<a name="SYS_CONNECTION_LOG"></a>

Logs authentication attempts and connections and disconnections.

SYS\$1CONNECTION\$1LOG is visible only to superusers. For more information, see [Visibility of data in system tables and views](cm_chap_system-tables.md#c_visibility-of-data).

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

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/redshift/latest/dg/SYS_CONNECTION_LOG.html)

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

To view the details for open connections, run the following query.

```
select record_time, user_name, database_name, remote_host, remote_port
from sys_connection_log
where event = 'initiating session'
and session_id not in 
(select session_id from sys_connection_log
where event = 'disconnecting session')
order by 1 desc;

record_time         | user_name   | database_name   | remote_host   | remote_port                      
--------------------+-------------+-----------------+---------------+---------------------------------
2014-11-06 20:30:06 | rdsdb       | dev             | [local]       |                            
2014-11-06 20:29:37 | test001     | test            | 10.49.42.138  | 11111                           
2014-11-05 20:30:29 | rdsdb       | dev             | 10.49.42.138  | 33333                                                 
2014-11-05 20:28:35 | rdsdb       | dev             | [local]       |  
(4 rows)
```

The following example reflects a failed authentication attempt and a successful connection and disconnection. 

```
select event, record_time, remote_host, user_name
from sys_connection_log order by record_time;            

            event      |         record_time        |  remote_host  | user_name                      
-----------------------+----------------------------+---------------+---------
authentication failure | 2012-10-25 14:41:56.96391  | 10.49.42.138  | john                                              
authenticated          | 2012-10-25 14:42:10.87613  | 10.49.42.138  | john                                              
initiating session     | 2012-10-25 14:42:10.87638  | 10.49.42.138  | john                                              
disconnecting session  | 2012-10-25 14:42:19.95992  | 10.49.42.138  | john                                              
(4 rows)
```

The following example shows the version of the ODBC driver, the operating system on the client machine, and the plugin used to connect to the Amazon Redshift cluster. In this example, the plugin used is for standard ODBC driver authentication using a login name and password.

```
select driver_version, os_version, plugin_name from sys_connection_log;
                
driver_version                          |  os_version                       | plugin_name
----------------------------------------+-----------------------------------+--------------------
Amazon Redshift ODBC Driver 1.4.15.0001 | Darwin 18.7.0 x86_64              | none
Amazon Redshift ODBC Driver 1.4.15.0001 | Linux 4.15.0-101-generic x86_64   | none
```

The following example shows the version of the operating system on the client machine, the driver version, and the protocol version.

```
select os_version, driver_version, protocol_version from sys_connection_log;
                
os_version                      |  driver_version              | protocol_version
--------------------------------+------------------------------+--------------------
Linux 4.15.0-101-generic x86_64 | Redshift JDBC Driver 2.0.0.0 | 2
Linux 4.15.0-101-generic x86_64 | Redshift JDBC Driver 2.0.0.0 | 2 
Linux 4.15.0-101-generic x86_64 | Redshift JDBC Driver 2.0.0.0 | 2
```

# SYS\$1COPY\$1JOB
<a name="SYS_COPY_JOB"></a>

Use SYS\$1COPY\$1JOB to view details of COPY JOB commands.

This view contains the COPY JOB commands that have been created.

SYS\$1COPY\$1JOB 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).

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

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/redshift/latest/dg/SYS_COPY_JOB.html)

# SYS\$1COPY\$1JOB\$1DETAIL
<a name="SYS_COPY_JOB_DETAIL"></a>

Use SYS\$1COPY\$1JOB\$1DETAIL to view details of COPY JOB commands.

This view contains the COPY JOB commands that have been created. If COPY JOB attempts to load a file and it fails to load, the file is skipped on future automatic COPY JOB attempts.

SYS\$1COPY\$1JOB\$1DETAIL 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).

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

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/redshift/latest/dg/SYS_COPY_JOB_DETAIL.html)

The following example returns one row where for ingested entries.

```
SELECT * FROM SYS_COPY_JOB_DETAIL WHERE status ilike '%ingested%' limit 1;


user_id | 100
database_name | dev
job_name | many_job_4_3
job_id | 110702
file_location | saral-sqs-system4623202051-0
file_name | frenzy-9/4623202051/file_0_107
file_size | 11302
file_etag | 51b2d78ac5b5aecf4ee6f8374815ad19
modification_time | 2024-07-15 20:43:14
enqueue_time | 2024-07-15 20:44:24
status | Ingested
```

# SYS\$1COPY\$1JOB\$1INFO
<a name="SYS_COPY_JOB_INFO"></a>

Use SYS\$1COPY\$1JOB\$1INFO to view messages logged about a COPY JOB.

This view contains information about errors in a COPY JOB that has run.

SYS\$1COPY\$1JOB\$1INFO 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).

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

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/redshift/latest/dg/SYS_COPY_JOB_INFO.html)

# SYS\$1COPY\$1REPLACEMENTS
<a name="SYS_COPY_REPLACEMENTS"></a>

Displays a log that records when invalid UTF-8 characters were replaced by the [COPY](r_COPY.md) command with the ACCEPTINVCHARS option. A log entry is added to SYS\$1COPY\$1REPLACEMENTS for each of the first 100 rows on each node slice that required at least one replacement. 

You can use this view to see information about serverless workgroups and provisioned clusters.

SYS\$1COPY\$1REPLACEMENTS 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).

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

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/redshift/latest/dg/SYS_COPY_REPLACEMENTS.html)

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

The following example returns replacements for the most recent COPY operation.

```
select query_idp, table_id, file_name, line_number, colname
from sys_copy_replacements
where query = pg_last_copy_id();


 query_id | table_id |   file_name                                           | line_number | column_name
 ---------+----------+-------------------------------------------------------+-------------+--------
    96    |    26    | s3://DOC-EXAMPLE-BUCKET/allusers_pipe.txt             |         123 | city
    96    |    26    | s3://DOC-EXAMPLE-BUCKET/allusers_pipe.txt             |         456 | city
    96    |    26    | s3://DOC-EXAMPLE-BUCKET/allusers_pipe.txt             |         789 | city
    96    |    26    | s3://DOC-EXAMPLE-BUCKET/allusers_pipe.txt             |         012 | city
    96    |    26    | s3://DOC-EXAMPLE-BUCKET/allusers_pipe.txt             |         119 | city
...
```

# SYS\$1DATASHARE\$1CHANGE\$1LOG
<a name="SYS_DATASHARE_CHANGE_LOG"></a>

Records the consolidated view for tracking changes to datashares on both producer and consumer clusters.

SYS\$1DATASHARE\$1CHANGE\$1LOG 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).

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

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/redshift/latest/dg/SYS_DATASHARE_CHANGE_LOG.html)

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

The following example shows a SYS\$1DATASHARE\$1CHANGE\$1LOG view.

```
SELECT DISTINCT action
FROM sys_datashare_change_log
WHERE share_object_name LIKE 'tickit%';

         action
 -----------------------
  "ALTER DATASHARE ADD"
```

# SYS\$1DATASHARE\$1CROSS\$1REGION\$1USAGE
<a name="r_SYS_DATASHARE_CROSS_REGION_USAGE"></a>

Use the SYS\$1DATASHARE\$1CROSS\$1REGION\$1USAGE view to get a summary of cross-Region data transferred usage caused by cross-Region datasharing query. SYS\$1DATASHARE\$1CROSS\$1REGION\$1USAGE aggregates details at the segment level.

SYS\$1DATASHARE\$1CROSS\$1REGION\$1USAGE is visible only to superusers. For more information, see [Visibility of data in system tables and views](cm_chap_system-tables.md#c_visibility-of-data).

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

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/redshift/latest/dg/r_SYS_DATASHARE_CROSS_REGION_USAGE.html)

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

The following example shows a SYS\$1DATASHARE\$1CROSS\$1REGION\$1USAGE view.

```
SELECT query_id, segment_id, transferred_data, source_region
from sys_datashare_cross_region_usage
where query_id = pg_last_query_id()
order by query_id, segment_id;

  query_id | segment_id | transferred_data | source_region 
-----------+------------+------------------+---------------
    200048 |          2 |          4194304 |    us-west-1  
    200048 |          2 |          4194304 |    us-east-2
```

# SYS\$1DATASHARE\$1USAGE\$1CONSUMER
<a name="SYS_DATASHARE_USAGE_CONSUMER"></a>

Records the activity and usage of datashares. This view is only relevant on the consumer cluster.

SYS\$1DATASHARE\$1USAGE\$1CONSUMER 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).

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

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/redshift/latest/dg/SYS_DATASHARE_USAGE_CONSUMER.html)

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

The following example shows the SYS\$1DATASHARE\$1USAGE\$1CONSUMER view.

```
SELECT request_type, status, trim(error) AS error
FROM sys_datashare_usage_consumer

  request_type  | status | error_message
----------------+--------+---------------
 "GET RELATION" |   0    |
```

# SYS\$1DATASHARE\$1USAGE\$1PRODUCER
<a name="SYS_DATASHARE_USAGE_PRODUCER"></a>

Records the activity and usage of datashares. This view is only relevant on the producer cluster.

SYS\$1DATASHARE\$1USAGE\$1PRODUCER 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).

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

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/redshift/latest/dg/SYS_DATASHARE_USAGE_PRODUCER.html)

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

The following example shows the SYS\$1DATASHARE\$1USAGE\$1PRODUCER view.

```
SELECT DISTINCT 
FROM sys_datashare_usage_producer 
WHERE object_name LIKE 'tickit%';
   
   request_type
 ------------------   
   "GET RELATION"
```

# SYS\$1EXTERNAL\$1QUERY\$1DETAIL
<a name="SYS_EXTERNAL_QUERY_DETAIL"></a>

Use SYS\$1EXTERNAL\$1QUERY\$1DETAIL to view details for queries at a segment level. Each row represents a segment from a particular WLM query with details like the number of rows processed, number of bytes processed, and partition info of external tables in Amazon S3. Each row in this view will also have a corresponding entry in the SYS\$1QUERY\$1DETAIL view, except this view has more detail information related to external query processing. 

SYS\$1EXTERNAL\$1QUERY\$1DETAIL 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).

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

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/redshift/latest/dg/SYS_EXTERNAL_QUERY_DETAIL.html)

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

The following query shows the external query details.

```
SELECT query_id,
       segment_id,
       start_time,
       end_time,
       total_partitions,
       qualified_partitions,
       scanned_files,
       returned_rows,
       returned_bytes,
       trim(external_query_text) query_text,
       trim(file_location) file_location
FROM sys_external_query_detail
ORDER BY query_id, start_time DESC
LIMIT 2;
```

Sample output.

```
 query_id | segment_id |         start_time         |          end_time          | total_partitions | qualified_partitions | scanned_files | returned_rows | returned_bytes | query_text | file_location
----------+------------+----------------------------+----------------------------+------------------+----------------------+---------------+---------------+----------------+------------+---------------
   763251 |          0 | 2022-02-15 22:32:23.312448 | 2022-02-15 22:32:24.036023 |                3 |                    3 |             3 |         38203 |        2683414 |            |
   763254 |          0 | 2022-02-15 22:32:40.17103  | 2022-02-15 22:32:40.839313 |                3 |                    3 |             3 |         38203 |        2683414 |            |
```

# SYS\$1EXTERNAL\$1QUERY\$1ERROR
<a name="SYS_EXTERNAL_QUERY_ERROR"></a>

You can query the system view SYS\$1EXTERNAL\$1QUERY\$1ERROR to get information about Redshift Spectrum scan errors. SYS\$1EXTERNAL\$1QUERY\$1ERROR displays a sample of logged errors. The default is 10 entries per query.

SYS\$1EXTERNAL\$1QUERY\$1ERROR 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).

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

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/redshift/latest/dg/SYS_EXTERNAL_QUERY_ERROR.html)

## Sample query
<a name="SYS_EXTERNAL_QUERY_ERROR-sample-query"></a>

The following query returns the list of rows for which data handling operations were performed. 

```
SELECT * FROM sys_external_query_error;
```

The query returns results similar to the following. 

```
   user_id   query_id  file_location                                rowid    column_name           original_value             modified_value       trigger          action               action_value                 error_code
     100     1574007   s3://spectrum-uddh/league/spi_global_rankings.0:0     league_name           Barclays Premier League    Barclays Premier Lea UNSPECIFIED      TRUNCATE                                          156
     100     1574007   s3://spectrum-uddh/league/spi_global_rankings.0:0     league_nspi           34595                      32767                UNSPECIFIED      OVERFLOW_VALUE                                    199
     100     1574007   s3://spectrum-uddh/league/spi_global_rankings.0:1     league_nspi           34151                      32767                UNSPECIFIED      OVERFLOW_VALUE                                    199
     100     1574007   s3://spectrum-uddh/league/spi_global_rankings.0:2     league_name           Barclays Premier League    Barclays Premier Lea UNSPECIFIED      TRUNCATE                                          156
     100     1574007   s3://spectrum-uddh/league/spi_global_rankings.0:2     league_nspi           33223                      32767                UNSPECIFIED      OVERFLOW_VALUE                                    199
     100     1574007   s3://spectrum-uddh/league/spi_global_rankings.0:3     league_name           Barclays Premier League    Barclays Premier Lea UNSPECIFIED      TRUNCATE                                          156
     100     1574007   s3://spectrum-uddh/league/spi_global_rankings.0:3     league_nspi           32808                      32767                UNSPECIFIED      OVERFLOW_VALUE                                    199
     100     1574007   s3://spectrum-uddh/league/spi_global_rankings.0:4     league_nspi           32790                      32767                UNSPECIFIED      OVERFLOW_VALUE                                    199
     100     1574007   s3://spectrum-uddh/league/spi_global_rankings.0:5     league_name           Spanish Primera Division   Spanish Primera Divi UNSPECIFIED      TRUNCATE                                          156
     100     1574007   s3://spectrum-uddh/league/spi_global_rankings.0:6     league_name           Spanish Primera Division   Spanish Primera Divi UNSPECIFIED      TRUNCATE                                          156
```

# SYS\$1EXTRA\$1COMPUTE\$1FOR\$1AUTOMATIC\$1OPTIMIZATION
<a name="SYS_EXTRA_COMPUTE_FOR_AUTOMATIC_OPTIMIZATION"></a>

Use SYS\$1EXTRA\$1COMPUTE\$1FOR\$1AUTOMATIC\$1OPTIMIZATION to view the usage periods in which Amazon Redshift ran automatic optimization tasks using extra compute resources. For more information on automatic optimization, see [Automatic database optimization](c_autonomics.md). For more information on automatic optimizations run using extra compute resources, see [Allocating extra compute resources for automatic database optimization](t_extra-compute-autonomics.md).

SYS\$1EXTRA\$1COMPUTE\$1FOR\$1AUTOMATIC\$1OPTIMIZATION is available only for provisioned clusters.

SYS\$1EXTRA\$1COMPUTE\$1FOR\$1AUTOMATIC\$1OPTIMIZATION is visible only to superusers. For more information, see [Visibility of data in system tables and views](cm_chap_system-tables.md#c_visibility-of-data).

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

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/redshift/latest/dg/SYS_EXTRA_COMPUTE_FOR_AUTOMATIC_OPTIMIZATION.html)

## Examples
<a name="SYS_EXTRA_COMPUTE_FOR_AUTOMATIC_OPTIMIZATION-examples"></a>

Following is an example query looking for automatic optimizations performed on September 16, 2025.

```
SELECT *
FROM sys_extra_compute_for_automatic_optimization
WHERE start_time BETWEEN '2025-09-16 00:00:00' AND '2025-09-16 23:59:59';

start_time           | end_time            | query_count | compute_seconds
---------------------+---------------------+-------------+-----------------
 2025-09-16 00:00:00  | 2025-09-16 00:00:59 | 1           | 59
 2025-09-16 00:01:05  | 2025-09-16 00:01:58 | 2           | 53
```

# SYS\$1INTEGRATION\$1ACTIVITY
<a name="r_SYS_INTEGRATION_ACTIVITY"></a>

SYS\$1INTEGRATION\$1ACTIVITY displays details about completed integration runs.

SYS\$1INTEGRATION\$1ACTIVITY is visible only to superusers. For more information, see [Visibility of data in system tables and views](cm_chap_system-tables.md#c_visibility-of-data).

For information about zero-ETL integrations, see [Working with zero-ETL integrations](https://docs.aws.amazon.com//redshift/latest/mgmt/zero-etl-using.html) in the Amazon Redshift Management Guide.

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

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/redshift/latest/dg/r_SYS_INTEGRATION_ACTIVITY.html)

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

The following SQL command displays the log of integrations. 

```
select * from sys_integration_activity;

          integration_id              | target_database | source |            checkpoint_name                  | checkpoint_type  | checkpoint_bytes | last_commit_timestamp   | modified_tables |   integration_start_time   |    integration_end_time
--------------------------------------+-----------------+--------+---------------------------------------------+------------------+------------------+-------------------------+-----------------+----------------------------+----------------------------
 76b15917-afae-4447-b7fd-08e2a5acce7b |   demo1         | MySQL  | checkpoints/checkpoint_3_241_3_510.json     |        cdc       |        762       | 2023-05-10 23:00:14.201 |         1       | 2023-05-10 23:00:45.054265 | 2023-05-10 23:00:46.339826
 76b15917-afae-4447-b7fd-08e2a5acce7b |   demo1         | MySQL  | checkpoints/checkpoint_3_16329_3_17839.json |        cdc       |       13488      | 2023-05-11 01:33:57.411 |         2       | 2023-05-11 02:19:09.440121 | 2023-05-11 02:19:16.090492
 76b15917-afae-4447-b7fd-08e2a5acce7b |   demo1         | MySQL  | checkpoints/checkpoint_3_5103_3_5532.json   |        cdc       |        1657      | 2023-05-10 23:13:14.205 |         2       | 2023-05-10 23:13:23.545487 | 2023-05-10 23:13:25.652144
```

# SYS\$1INTEGRATION\$1TABLE\$1ACTIVITY
<a name="r_SYS_INTEGRATION_TABLE_ACTIVITY"></a>

SYS\$1INTEGRATION\$1TABLE\$1ACTIVITY displays details of insert, delete, and update activity of zero-ETL integrations. There is one row added for each completed ingestion.

A superuser can see all rows in this table.

For more information, see [zero-ETL integrations](https://docs.aws.amazon.com//redshift/latest/mgmt/zero-etl-using.html).

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

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/redshift/latest/dg/r_SYS_INTEGRATION_TABLE_ACTIVITY.html)

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

The following SQL command displays activity of the integration. 

```
select * from sys_integration_table_activity;

          integration_id              | checkpoint_name | target_database | schema_name |     table_name    | table_id     | record_time                | transaction_id  | inserted_rows  | deleted_rows | updated_rows | bytes_ingested 
--------------------------------------+-----------------+-----------------+-------------+-------------------+--------------+----------------------------+-----------------+----------------+--------------+--------------+---------------
 4798e675-8f9f-4686-b05f-92c538e19629 |                 | sample_test2    |    sample   | SampleTestChannel |  111276      | 2023-05-12 12:40:30.656625 | 7736            |  2             | 0            | 0            | 125
```

# SYS\$1INTEGRATION\$1TABLE\$1STATE\$1CHANGE
<a name="r_SYS_INTEGRATION_TABLE_STATE_CHANGE"></a>

SYS\$1INTEGRATION\$1TABLE\$1STATE\$1CHANGE displays details about table state change logs for integrations.

A superuser can see all rows in this table.

For more information, see [Working with Zero-ETL integrations](https://docs.aws.amazon.com//redshift/latest/mgmt/zero-etl-using.html).

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

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/redshift/latest/dg/r_SYS_INTEGRATION_TABLE_STATE_CHANGE.html)

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

The following SQL command displays the log of integrations. 

```
select * from sys_integration_table_state_change;
                
            integration_id            | database_name | schema_name | table_name | new_state |  table_last_replicated_checkpoint   | state_change_reason |        record_time
--------------------------------------+---------------+-------------+------------+-----------+-------------------------------------+---------------------+----------------------------
 99108e72-1cfd-414f-8cc0-0216acefac77 | perfdb        | sbtest80t3s | sbtest79   | Synced    | {"txn_seq":9834,"txn_id":126597515} |                     | 2023-09-20 19:39:50.087868
 99108e72-1cfd-414f-8cc0-0216acefac77 | perfdb        | sbtest80t3s | sbtest56   | Synced    | {"txn_seq":9834,"txn_id":126597515} |                     | 2023-09-20 19:39:45.54005
 99108e72-1cfd-414f-8cc0-0216acefac77 | perfdb        | sbtest80t3s | sbtest50   | Synced    | {"txn_seq":9834,"txn_id":126597515} |                     | 2023-09-20 19:40:20.362504
 99108e72-1cfd-414f-8cc0-0216acefac77 | perfdb        | sbtest80t3s | sbtest18   | Synced    | {"txn_seq":9834,"txn_id":126597515} |                     | 2023-09-20 19:40:32.544084
 99108e72-1cfd-414f-8cc0-0216acefac77 | perfdb        | sbtest40t3s | sbtest23   | Synced    | {"txn_seq":9834,"txn_id":126597515} |                     | 2023-09-20 15:49:05.186209
```

# SYS\$1LOAD\$1DETAIL
<a name="SYS_LOAD_DETAIL"></a>

Returns information to track or troubleshoot a data load.

This view records the progress of each data file as it is loaded into a database table. 

This view 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). 

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

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/redshift/latest/dg/SYS_LOAD_DETAIL.html)

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

The following example returns details for the last COPY operation. 

```
select query_id, trim(file_name) as file, record_time
from sys_load_detail
where query_id = pg_last_copy_id();

 query_id |               file               |          record_time        
----------+----------------------------------+----------------------------
 28554    | s3://dw-tickit/category_pipe.txt | 2013-11-01 17:14:52.648486 
(1 row)
```

The following query contains entries for a fresh load of the tables in the TICKIT database: 

```
select query_id, trim(file_name), record_time
from sys_load_detail
where file_name like '%tickit%' order by query_id;

 query_id |           btrim          |          record_time          
----------+--------------------------+----------------------------
 22475    | tickit/allusers_pipe.txt | 2013-02-08 20:58:23.274186 
 22478    | tickit/venue_pipe.txt    | 2013-02-08 20:58:25.070604  
 22480    | tickit/category_pipe.txt | 2013-02-08 20:58:27.333472 
 22482    | tickit/date2008_pipe.txt | 2013-02-08 20:58:28.608305  
 22485    | tickit/allevents_pipe.txt| 2013-02-08 20:58:29.99489    
 22487    | tickit/listings_pipe.txt | 2013-02-08 20:58:37.632939 
 22593    | tickit/allusers_pipe.txt | 2013-02-08 21:04:08.400491  
 22596    | tickit/venue_pipe.txt    | 2013-02-08 21:04:10.056055  
 22598    | tickit/category_pipe.txt | 2013-02-08 21:04:11.465049  
 22600    | tickit/date2008_pipe.txt | 2013-02-08 21:04:12.461502  
 22603    | tickit/allevents_pipe.txt| 2013-02-08 21:04:14.785124  
 22605    | tickit/listings_pipe.txt | 2013-02-08 21:04:20.170594  

(12 rows)
```

The fact that a record is written to the log file for this system view does not mean that the load committed successfully as part of its containing transaction. To verify load commits, query the STL\$1UTILITYTEXT view and look for the COMMIT record that corresponds with a COPY transaction. For example, this query joins SYS\$1LOAD\$1DETAIL and STL\$1QUERY based on a subquery against STL\$1UTILITYTEXT: 

```
select l.query_id,rtrim(l.file_name),q.transaction_id
from sys_load_detail l, sys_query_text q
where l.query_id=q.query_id
and exists
(select xid from stl_utilitytext where xid=q.transaction_id and rtrim("text")='COMMIT');

 query_id |           rtrim           |  transaction_id
----------+---------------------------+-----------------
 22600    | tickit/date2008_pipe.txt  | 68311
 22480    | tickit/category_pipe.txt  | 68066
  7508    | allusers_pipe.txt         | 23365
  7552    | category_pipe.txt         | 23415
  7576    | allevents_pipe.txt        | 23429
  7516    | venue_pipe.txt            | 23390
  7604    | listings_pipe.txt         | 23445
 22596    | tickit/venue_pipe.txt     | 68309
 22605    | tickit/listings_pipe.txt  | 68316
 22593    | tickit/allusers_pipe.txt  | 68305
 22485    | tickit/allevents_pipe.txt | 68071
  7561    | allevents_pipe.txt        | 23429
  7541    | category_pipe.txt         | 23415
  7558    | date2008_pipe.txt         | 23428
 22478    | tickit/venue_pipe.txt     | 68065
   526    | date2008_pipe.txt         |  2572
  7466    | allusers_pipe.txt         | 23365
 22482    | tickit/date2008_pipe.txt  | 68067
 22598    | tickit/category_pipe.txt  | 68310
 22603    | tickit/allevents_pipe.txt | 68315
 22475    | tickit/allusers_pipe.txt  | 68061
   547    | date2008_pipe.txt         |  2572
 22487    | tickit/listings_pipe.txt  | 68072
  7531    | venue_pipe.txt            | 23390
  7583    | listings_pipe.txt         | 23445
(25 rows)
```

# SYS\$1LUDF\$1DETAIL
<a name="SYS_LUDF_DETAIL"></a>

SYS\$1LUDF\$1DETAIL records information and metrics for Lambda User Defined Functions (LUDFs) that were used in a particular query.

SYS\$1LUDF\$1DETAIL is visible only to superusers. For more information, see [Visibility of data in system tables and views](cm_chap_system-tables.md#c_visibility-of-data).

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

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/redshift/latest/dg/SYS_LUDF_DETAIL.html)

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

The following example uses a Lambda UDF in a query, and then shows how to query the SYS\$1LUDF\$1DETAIL view to see the function execution details.

```
SET SESSION AUTHORIZATION regular_user;

CREATE EXTERNAL FUNCTION exfunc_sum(INT,INT) RETURNS INT STABLE
LAMBDA 'lambda_sum'
IAM_ROLE 'arn:aws:iam::123456789012:role/Redshift-Exfunc-Test';

CREATE TABLE t_sum(c1 int, c2 int);
INSERT INTO t_sum VALUES (4,5), (6,7);
SELECT exfunc_sum(c1,c2) FROM t_sum;

-- Switch to super user in order to inspect records in the LUDF SYS view.
SET SESSION AUTHORIZATION super_user;
select * from sys_ludf_detail;
```

Sample output:

```
 user_id | transaction_id | query_id | function_oid | function_position | stream_id | segment_id | step_id | lambda_function_name |         start_time         |          end_time          | total_duration | invocations | total_rows | input_bytes | output_bytes
---------+----------------+----------+--------------+-------------------+-----------+------------+---------+----------------------+----------------------------+----------------------------+----------------+-------------+------------+-------------+--------------
     100 |           1463 |     1544 |       111055 |                 0 |         0 |          0 |       2 | lambda_sum           | 2026-01-06 17:23:25.165898 | 2026-01-06 17:23:25.165898 |            414 |           1 |          2 |         277 |           18
(1 row)
```

# SYS\$1LOAD\$1ERROR\$1DETAIL
<a name="SYS_LOAD_ERROR_DETAIL"></a>

Use SYS\$1LOAD\$1ERROR\$1DETAIL to view details of COPY command errors. Each row represents a COPY command. It contains both running and finished COPY commands.

SYS\$1LOAD\$1ERROR\$1DETAIL 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).

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

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/redshift/latest/dg/SYS_LOAD_ERROR_DETAIL.html)

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

The following query shows the load error details of copy command for specific query.

```
SELECT query_id,
       table_id,
       start_time,
       trim(file_name) AS file_name, 
       trim(column_name) AS column_name, 
       trim(column_type) AS column_type, 
       trim(error_message) AS error_message 
FROM sys_load_error_detail 
WHERE query_id = 762949 
ORDER BY start_time 
LIMIT 10;
```

Sample output.

```
 query_id | table_id |         start_time         |               file_name                  | column_name | column_type |                 error_message
----------+----------+----------------------------+------------------------------------------+-------------+-------------+------------------------------------------------
   762949 |   137885 | 2022-02-15 22:14:46.759151 | s3://load-test/copyfail/wrong_format_000 | id          | int4        | Invalid digit, Value 'a', Pos 0, Type: Integer
   762949 |   137885 | 2022-02-15 22:14:46.759151 | s3://load-test/copyfail/wrong_format_001 | id          | int4        | Invalid digit, Value 'a', Pos 0, Type: Integer
```

# SYS\$1LOAD\$1HISTORY
<a name="SYS_LOAD_HISTORY"></a>

Use SYS\$1LOAD\$1HISTORY to view details of COPY commands. Each row represents a COPY command with accumulated statistics for some of the fields. It contains both running and finished COPY commands.

SYS\$1LOAD\$1HISTORY 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).

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

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/redshift/latest/dg/SYS_LOAD_HISTORY.html)

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

The following query shows the loaded rows, bytes, tables, and datasource of specific copy commands.

```
SELECT query_id,
       table_name,
       data_source,
       loaded_rows,
       loaded_bytes
FROM sys_load_history
WHERE query_id IN (6389,490791,441663,74374,72297)
ORDER BY query_id,
         data_source DESC;
```

Sample output.

```
 query_id |    table_name    |                               data_source                             | loaded_rows | loaded_bytes
----------+------------------+-----------------------------------------------------------------------+-------------+---------------
     6389 | store_returns    | s3://load-test/data-sources/tpcds/2.8.0/textfile/1T/store_returns/    |   287999764 | 1196240296158
    72297 | web_site         | s3://load-test/data-sources/tpcds/2.8.0/textfile/1T/web_site/         |          54 |         43808
    74374 | ship_mode        | s3://load-test/data-sources/tpcds/2.8.0/textfile/1T/ship_mode/        |          20 |          1320
   441663 | income_band      | s3://load-test/data-sources/tpcds/2.8.0/textfile/1T/income_band/      |          20 |          2152
   490791 | customer_address | s3://load-test/data-sources/tpcds/2.8.0/textfile/1T/customer_address/ |     6000000 |     722924305
```

The following query shows the loaded rows, bytes, tables, and datasource of copy commands.

```
SELECT query_id,
       table_name,
       data_source,
       loaded_rows,
       loaded_bytes
FROM sys_load_history
ORDER BY query_id DESC
LIMIT 10;
```

Sample output.

```
 query_id |       table_name       |                                 data_source                                 | loaded_rows |  loaded_bytes
----------+------------------------+-----------------------------------------------------------------------------+-------------+-----------------
   491058 | web_site               | s3://load-test/data-sources/tpcds/2.8.0/textfile/1T/web_site/               |          54 |           43808
   490947 | web_sales              | s3://load-test/data-sources/tpcds/2.8.0/textfile/1T/web_sales/              |   720000376 |  22971988122819
   490923 | web_returns            | s3://load-test/data-sources/tpcds/2.8.0/textfile/1T/web_returns/            |    71997522 |     96597496325
   490918 | web_page               | s3://load-test/data-sources/tpcds/2.8.0/textfile/1T/web_page/               |        3000 |            1320
   490907 | warehouse              | s3://load-test/data-sources/tpcds/2.8.0/textfile/1T/warehouse/              |          20 |            1320
   490902 | time_dim               | s3://load-test/data-sources/tpcds/2.8.0/textfile/1T/time_dim/               |       86400 |            1320
   490876 | store_sales            | s3://load-test/data-sources/tpcds/2.8.0/textfile/1T/store_sales/            |  2879987999 | 151666241887933
   490870 | store_returns          | s3://load-test/data-sources/tpcds/2.8.0/textfile/1T/store_returns/          |   287999764 |   1196405607941
   490865 | store                  | s3://load-test/data-sources/tpcds/2.8.0/textfile/1T/store/                  |        1002 |          365507
```

 The following query shows the daily loaded rows and bytes of the copy command. 

```
SELECT date_trunc('day',start_time) AS exec_day,
       SUM(loaded_rows) AS loaded_rows,
       SUM(loaded_bytes) AS loaded_bytes
FROM sys_load_history
GROUP BY exec_day
ORDER BY exec_day DESC;
```

Sample output.

```
      exec_day       | loaded_rows |   loaded_bytes
---------------------+-------------+------------------
 2022-01-20 00:00:00 |  6347386005 |  258329473070606
 2022-01-19 00:00:00 | 19042158015 |  775198502204572
 2022-01-18 00:00:00 | 38084316030 | 1550294469446883
 2022-01-17 00:00:00 | 25389544020 | 1033271084791724
 2022-01-16 00:00:00 | 19042158015 |  775222736252792
 2022-01-15 00:00:00 | 19834245387 |  798122849155598
 2022-01-14 00:00:00 | 75376544688 | 3077040926571384
```

# SYS\$1MV\$1REFRESH\$1HISTORY
<a name="SYS_MV_REFRESH_HISTORY"></a>

The results include information about the refresh history of all materialized views. The results include the refresh type, such as manual or auto, and the status of the most recent refresh. 

SYS\$1MV\$1REFRESH\$1HISTORY 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).

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

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/redshift/latest/dg/SYS_MV_REFRESH_HISTORY.html)

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

The following query shows the refresh history for materialized views.

```
SELECT user_id, 
     session_id, 
     transaction_id, 
     database_name, 
     schema_name, 
     mv_id, 
     mv_name,
     refresh_type,
     status,
     start_time,
     end_time,
     duration,
     consumer_account,
     consumer_region,
     consumer_namespace
     from sys_mv_refresh_history;
```

The query returns the following sample output:

```
 user_id | session_id | transaction_id | database_name | schema_name                | mv_id  |  mv_name           |  refresh_type  |  status                                                                                              |  start_time                |  end_time                  |  duration | consumer_account | consumer_region | consumer_namespace
---------+------------+----------------+---------------+----------------------------+--------+--------------------+----------------+------------------------------------------------------------------------------------------------------+----------------------------+----------------------------+-----------+------------------+-----------------+------------------------------------
       1 | 1073815659 |          15066 | dev           | test_stl_mv_refresh_schema | 203762 | mv_incremental     | Manual         | MV was already updated                                                                               | 2023-10-26 15:59:20.952179 | 2023-10-26 15:59:20.952866 |      687 |                  |                 |
       1 | 1073815659 |          15068 | dev           | test_stl_mv_refresh_schema | 203771 | mv_nonincremental  | Manual         | MV was already updated                                                                               | 2023-10-26 15:59:21.008049 | 2023-10-26 15:59:21.008658 |      609 |                  |                 |
       1 | 1073815659 |          15070 | ext_db        | producer_schema            | 203779 | producer_mv        | Manual         | Refresh successfully updated MV incrementally                                                        | 2023-10-26 15:59:21.064252 | 2023-10-26 15:59:21.064885 |      633 | 0123456789       | us-east-1       | 623d8ff2-4391-4381-83d7-177caa6767af
       1 | 1073815659 |          15074 | dev           | test_stl_mv_refresh_schema | 203762 | mv_incremental     | Manual         | Refresh successfully updated MV incrementally                                                        | 2023-10-26 15:59:29.693329 | 2023-10-26 15:59:43.482842 | 13789513 |                  |                 |
       1 | 1073815659 |          15076 | dev           | test_stl_mv_refresh_schema | 203771 | mv_nonincremental  | Manual         | Refresh successfully recomputed MV from scratch                                                      | 2023-10-26 15:59:43.550184 | 2023-10-26 15:59:47.880833 |  4330649 |                  |                 |
       1 | 1073815659 |          15078 | dev           | test_stl_mv_refresh_schema | 203779 | mv_refresh_error   | Manual         | Refresh failed due to an internal error                                                              | 2023-10-26 15:59:47.949052 | 2023-10-26 15:59:52.494681 |  4545629 |                  |                 |
       1 | 1073815659 |          15071 | dev           | test_stl_mv_refresh_schema | 203778 | mv_test            | Manual         | Cascade refresh failed because materialized view test_stl_mv_refresh_schema.child was not refreshed. | 2023-10-26 15:30:21.432252 | 2023-10-26 15:30:21.432252 |      532 |                  |                 |
       1 | 1073815659 |          15071 | dev           | test_stl_mv_refresh_schema | 203761 | child              | Manual         | Refresh failed due to an internal error.                                                             | 2023-10-26 15:30:21.432252 | 2023-10-26 15:30:21.432252 |      532 |                  |                 |
       1 | 1073815659 |          15069 | dev           | test_stl_mv_refresh_schema | 203778 | mv_test            | Manual         | Cascade refresh skipped because materialized view test_stl_mv_refresh_schema.child was not refreshed.| 2023-10-26 15:21:43.550369 | 2023-10-26 15:21:43.550369 |      633
       1 | 1073815659 |          15069 | dev           | test_stl_mv_refresh_schema | 203761 | child              | Manual         | Refresh failed due to an internal error.                                                             | 2023-10-26 15:21:43.550369 | 2023-10-26 15:21:43.550369 |      633
(10 rows)
```

# SYS\$1MV\$1STATE
<a name="SYS_MV_STATE"></a>

The results include information about the state of all materialized views. It includes base table information, schema properties, and information about recent events, like dropping a column.

SYS\$1MV\$1STATE 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).

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

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/redshift/latest/dg/SYS_MV_STATE.html)

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

The following query shows the materialized view state.

```
select * from sys_mv_state;
```

The query returns the following sample output:

```
 user_id | transaction_id | database_name | event_desc                  | start_time                 | base_table_database_name | base_table_schema | base_table_name     |  mv_schema  | mv_name                    | state 
---------+----------------+---------------+-----------------------------+----------------------------+--------------------------+-------------------+---------------------+-------------+----------------------------+--------------
 106     | 12720          | tickit_db     | TRUNCATE                    | 2023-07-26 14:59:12.788268 | tickit_db                | mv_schema         | test_table_95d6d861 | mv_schema   | materialized_view_a1f3f862 | Recompute
 106     | 12724          | tickit_db     | ALTER TABLE ALTER DISTSTYLE | 2023-07-26 14:59:51.409014 | tickit_db                | mv_schema         | test_table_58102435 | mv_schema   | materialized_view_ca746631 | Recompute
 106     | 12720          | tickit_db     | Column was renamed          | 2023-07-26 14:59:12.822928 | tickit_db                | mv_schema         | test_table_95d6d861 | mv_schema   | materialized_view_5750a8d4 | Unrefreshable
 106     | 12727          | tickit_db     | Table was renamed           | 2023-07-26 15:00:08.051244 | tickit_db                | mv_schema         | test_table_95d6d861 | mv_schema   | materialized_view_5750a8d4 | Unrefreshable
 106     | 12720          | tickit_db     | Column was renamed          | 2023-07-26 14:59:12.857755 | tickit_db                | mv_schema         | test_table_95d6d861 | mv_schema   | materialized_view_5750a8d4 | Unrefreshable
 106     | 12727          | tickit_db     | Table was renamed           | 2023-07-26 15:00:08.051358 | tickit_db                | mv_schema         | test_table_95d6d861 | mv_schema   | materialized_view_5ef0d754 | Unrefreshable
 106     | 12720          | tickit_db     | TRUNCATE                    | 2023-07-26 14:59:12.788159 | tickit_db                | mv_schema         | test_table_95d6d861 | mv_schema   | materialized_view_5750a8d4 | Recompute
 106     | 12720          | tickit_db     | Column was renamed          | 2023-07-26 14:59:12.857799 | tickit_db                | mv_schema         | test_table_95d6d861 | mv_schema   | materialized_view_a1f3f862 | Unrefreshable
 106     | 12720          | tickit_db     | TRUNCATE                    | 2023-07-26 14:59:12.788327 | tickit_db                | mv_schema         | test_table_95d6d861 | mv_schema   | materialized_view_5ef0d754 | Recompute
 106     | 12727          | tickit_db     | ALTER TABLE ALTER SORTKEY   | 2023-07-26 15:00:08.006235 | tickit_db                | mv_schema         | test_table_58102435 | mv_schema   | materialized_view_ca746631 | Recompute
 106     | 12720          | tickit_db     | Column was renamed          | 2023-07-26 14:59:12.82297  | tickit_db                | mv_schema         | test_table_95d6d861 | mv_schema   | materialized_view_a1f3f862 | Unrefreshable
 106     | 12727          | tickit_db     | Table was renamed           | 2023-07-26 15:00:08.051321 | tickit_db                | mv_schema         | test_table_95d6d861 | mv_schema   | materialized_view_a1f3f862 | Unrefreshable
```

# SYS\$1PROCEDURE\$1CALL
<a name="SYS_PROCEDURE_CALL"></a>

Use the SYS\$1PROCEDURE\$1CALL view to get information about stored procedure calls, including start time, end time, status of a stored procedure call, and call hierarchy for nested stored procedure calls. Each stored procedure call receives a query ID.

SYS\$1PROCEDURE\$1CALL 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).

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

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/redshift/latest/dg/SYS_PROCEDURE_CALL.html)

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

The following query returns a nested stored procedure call hierarchy.

```
select query_id, datediff(seconds, start_time, end_time) as elapsed_time, status, trim(query_text) as call, caller_procedure_query_id from sys_procedure_call;
```

Sample output.

```
 query_id | elapsed_time | status  |                       call                       | caller_procedure_query_id 
----------+--------------+---------+--------------------------------------------------+---------------------------
     3087 |           18 | success | CALL proc_bd906c98c45443ffa165e9552056902d(1)    |          3085
     3085 |           18 | success | CALL proc_bd906c98c45443ffa165e9552056902d_2(1); |                          
(2 rows)
```

# SYS\$1PROCEDURE\$1MESSAGES
<a name="SYS_PROCEDURE_MESSAGES"></a>

SYS\$1PROCEDURE\$1MESSAGES 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).

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

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/redshift/latest/dg/SYS_PROCEDURE_MESSAGES.html)

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

The following query shows sample output of SYS\$1PROCEDURE\$1MESSAGES.

```
select transaction_id, query_id, record_time, log_level, trim(message), line_number from sys_procedure_messages;
```

```
transaction_id | query_id |        record_time         | log_level |           btrim           | line_number
---------------+----------+----------------------------+-----------+---------------------------+-------------
     25267     |   80562  | 2023-07-17 14:38:31.910136 |   NOTICE  | test_notice_msg_b9f1e749  |     8
     25267     |   80562  | 2023-07-17 14:38:31.910002 |    LOG    |  test_log_msg_833c7420    |     6
     25267     |   80562  | 2023-07-17 14:38:31.910111 |    INFO   |  test_info_msg_651373d9   |     7
     25267     |   80562  | 2023-07-17 14:38:31.910154 |   WARNING | test_warning_msg_831c5747 |     9
(4 rows)
```

# SYS\$1QUERY\$1DETAIL
<a name="SYS_QUERY_DETAIL"></a>

Use SYS\$1QUERY\$1DETAIL to view details for queries at various metric levels, with each row representing details about a particular WLM query at a given metric level. This view contains many types of queries such as DDL, DML, and utility commands (for example, copy and unload). Some columns might not be relevant depending on the query type. For example, external\$1scanned\$1bytes is not relevant to internal tables.

SYS\$1QUERY\$1DETAIL 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).

**Note**  
To verify whether a transaction containing the executed query was successfully committed, you need to perform a join operation between system tables and the `sys_transaction_history` table. For example:  

```
SELECT 
    th.transaction_id,
    qd.query_id,
    th.status AS transaction_status
FROM 
    sys_query_detail qd
LEFT JOIN sys_query_history qh ON qd.query_id = qh.query_id
LEFT JOIN sys_transaction_history th on qh.transaction_id = th.transaction_id;
```

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

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/redshift/latest/dg/SYS_QUERY_DETAIL.html)

## Usage notes
<a name="SYS_QUERY_DETAIL-usage-notes"></a>

SYS\$1QUERY\$1DETAIL can contain metrics at the step, steam, segment, and child query level. In addition to referencing the metrics\$1level column, you can see which metric level a given row is showing by referencing the step\$1id, segment\$1id, and stream\$1id fields according to the following table.

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/redshift/latest/dg/SYS_QUERY_DETAIL.html)

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

The following example returns the output of SYS\$1QUERY\$1DETAIL.

The following query shows the query metadata detail at step level, including step name, input\$1bytes, output\$1bytes, input\$1rows, output\$1rows.

```
SELECT query_id,
       child_query_sequence,
       stream_id,
       segment_id,
       step_id,
       trim(step_name) AS step_name,
       duration,
       input_bytes,
       output_bytes,
       input_rows,
       output_rows
FROM sys_query_detail
WHERE query_id IN (193929)
ORDER BY query_id,
         stream_id,
         segment_id,
         step_id DESC;
```

Sample output.

```
 query_id | child_query_sequence | stream_id | segment_id | step_id | step_name  |    duration     | input_bytes | output_bytes | input_rows | output_rows
----------+----------------------+-----------+------------+---------+------------+-----------------+-------------+--------------+------------+-------------
   193929 |                    2 |         0 |          0 |       3 | hash       |           37144 |           0 |      9350272 |          0 |      292196
   193929 |                    5 |         0 |          0 |       3 | hash       |            9492 |           0 |        23360 |          0 |        1460
   193929 |                    1 |         0 |          0 |       3 | hash       |           46809 |           0 |      9350272 |          0 |      292196
   193929 |                    4 |         0 |          0 |       2 | return     |            7685 |           0 |          896 |          0 |         112
   193929 |                    1 |         0 |          0 |       2 | project    |           46809 |           0 |            0 |          0 |      292196
   193929 |                    2 |         0 |          0 |       2 | project    |           37144 |           0 |            0 |          0 |      292196
   193929 |                    5 |         0 |          0 |       2 | project    |            9492 |           0 |            0 |          0 |        1460
   193929 |                    3 |         0 |          0 |       2 | return     |           11033 |           0 |        14336 |          0 |         112
   193929 |                    2 |         0 |          0 |       1 | project    |           37144 |           0 |            0 |          0 |      292196
   193929 |                    1 |         0 |          0 |       1 | project    |           46809 |           0 |            0 |          0 |      292196
   193929 |                    5 |         0 |          0 |       1 | project    |            9492 |           0 |            0 |          0 |        1460
   193929 |                    3 |         0 |          0 |       1 | aggregate  |           11033 |           0 |       201488 |          0 |          14
   193929 |                    4 |         0 |          0 |       1 | aggregate  |            7685 |           0 |        28784 |          0 |          14
   193929 |                    5 |         0 |          0 |       0 | scan       |            9492 |           0 |        23360 |     292196 |        1460
   193929 |                    4 |         0 |          0 |       0 | scan       |            7685 |           0 |         1344 |        112 |         112
   193929 |                    2 |         0 |          0 |       0 | scan       |           37144 |           0 |      7304900 |     292196 |      292196
   193929 |                    3 |         0 |          0 |       0 | scan       |           11033 |           0 |        13440 |        112 |         112
   193929 |                    1 |         0 |          0 |       0 | scan       |           46809 |           0 |      7304900 |     292196 |      292196
   193929 |                    5 |         0 |          0 |      -1 |            |            9492 |       12288 |            0 |          0 |           0
   193929 |                    1 |         0 |          0 |      -1 |            |           46809 |       16384 |            0 |          0 |           0
   193929 |                    2 |         0 |          0 |      -1 |            |           37144 |       16384 |            0 |          0 |           0
   193929 |                    4 |         0 |          0 |      -1 |            |            7685 |       28672 |            0 |          0 |           0
   193929 |                    3 |         0 |          0 |      -1 |            |           11033 |      114688 |            0 |          0 |           0
```

To view the tables in your database in order from most used to least used, use the following example. Replace *sample\$1data\$1dev* with your own database. Note that this query will count queries starting when your cluster is created, but your system view data is not saved when your data warehouse is lacking space.

```
SELECT table_name, COUNT (DISTINCT query_id) 
FROM SYS_QUERY_DETAIL 
WHERE table_name LIKE 'sample_data_dev%'
GROUP BY table_name
ORDER BY COUNT(*) DESC;

+---------------------------------+-------+
|           table_name            | count |
+---------------------------------+-------+
| sample_data_dev.tickit.venue    |     4 |
| sample_data_dev.myunload1.venue |     3 |
| sample_data_dev.tickit.listing  |     1 |
| sample_data_dev.tickit.category |     1 |
| sample_data_dev.tickit.users    |     1 |
| sample_data_dev.tickit.date     |     1 |
| sample_data_dev.tickit.sales    |     1 |
| sample_data_dev.tickit.event    |     1 |
+---------------------------------+-------+
```

 The following example shows the various metric levels for a single WLM query. 

```
SELECT query_id, child_query_sequence, stream_id, segment_id, step_id, step_name, start_time, end_time, metrics_level 
FROM sys_query_detail 
WHERE query_id = 1553 AND step_id = -1 
ORDER BY stream_id, segment_id, step_id;

 query_id | child_query_sequence | stream_id | segment_id | step_id | step_name |         start_time         |          end_time          | metrics_level 
----------+----------------------+-----------+------------+---------+-----------+----------------------------+----------------------------+---------------
     1553 |                    1 |        -1 |         -1 |      -1 |           | 2024-10-17 02:28:49.814721 | 2024-10-17 02:28:49.847838 | child query
     1553 |                    1 |         0 |         -1 |      -1 |           | 2024-10-17 02:28:49.814721 | 2024-10-17 02:28:49.835609 | stream
     1553 |                    1 |         0 |          0 |      -1 |           | 2024-10-17 02:28:49.824677 | 2024-10-17 02:28:49.830372 | segment
     1553 |                    1 |         1 |         -1 |      -1 |           | 2024-10-17 02:28:49.835624 | 2024-10-17 02:28:49.845773 | stream
     1553 |                    1 |         1 |          1 |      -1 |           | 2024-10-17 02:28:49.84088  | 2024-10-17 02:28:49.842388 | segment
     1553 |                    1 |         1 |          2 |      -1 |           | 2024-10-17 02:28:49.835926 | 2024-10-17 02:28:49.844396 | segment
     1553 |                    1 |         2 |         -1 |      -1 |           | 2024-10-17 02:28:49.846949 | 2024-10-17 02:28:49.847838 | stream
     1553 |                    1 |         2 |          3 |      -1 |           | 2024-10-17 02:28:49.847013 | 2024-10-17 02:28:49.847485 | segment
(8 rows)
```

# SYS\$1QUERY\$1EXPLAIN
<a name="SYS_QUERY_EXPLAIN"></a>

Displays the EXPLAIN plan for a query that has been submitted for execution.

SYS\$1QUERY\$1EXPLAIN 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).

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

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/redshift/latest/dg/SYS_QUERY_EXPLAIN.html)

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

The following example is the EXPLAIN plan of a single query.

```
SELECT * FROM sys_query_explain WHERE query_id = 612635 ORDER BY plan_node_id;

 userid | query_id | child_query_sequence | plan_node_id | plan_parent_id |                                                                                                                                                                                                    plan_node                                                                                                                                                                                                     |                                                                                                                                                                                                    plan_info                                                                                                                                                                                                     
--------+----------+----------------------+--------------+----------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    100 |   612635 |                    1 |            1 |              0 | XN Limit  (cost=3604047533041.00..3604047533041.25 rows=100 width=20)                                                                                                                                                                                                                                                                                                                                            |                                                                                                                                                                                                                                                                                                                                                                                                                 
    100 |   612635 |                    1 |            2 |              1 |   ->  XN Merge  (cost=3604047533041.00..3604047533148.02 rows=42809 width=20)                                                                                                                                                                                                                                                                                                                                    | Merge Key: sum(b.totalprice)                                                                                                                                                                                                                                                                                                                                                                                    
    100 |   612635 |                    1 |            3 |              2 |         ->  XN Network  (cost=3604047533041.00..3604047533148.02 rows=42809 width=20)                                                                                                                                                                                                                                                                                                                            |   Send to leader                                                                                                                                                                                                                                                                                                                                                                                                
    100 |   612635 |                    1 |            4 |              3 |               ->  XN Sort  (cost=3604047533041.00..3604047533148.02 rows=42809 width=20)                                                                                                                                                                                                                                                                                                                         | Sort Key: sum(b.totalprice)                                                                                                                                                                                                                                                                                                                                                                                     
    100 |   612635 |                    1 |            5 |              4 |                     ->  XN HashAggregate  (cost=2604047529640.76..2604047529747.78 rows=42809 width=20)                                                                                                                                                                                                                                                                                                          |                                                                                                                                                                                                                                                                                                                                                                                                                 
    100 |   612635 |                    1 |            6 |              5 |                           ->  XN Hash Join DS_DIST_NONE  (cost=15104956.16..2602364653507.34 rows=336575226684 width=20)                                                                                                                                                                                                                                                                                         | Hash Cond: (("outer".listid = "inner".listid) AND ("outer".sellerid = "inner".sellerid))                                                                                                                                                                                                                                                                                                                        
    100 |   612635 |                    1 |            7 |              6 |                                 ->  XN Seq Scan on listing b  (cost=0.00..7884677.12 rows=788467712 width=24)                                                                                                                                                                                                                                                                                                    |                                                                                                                                                                                                                                                                                                                                                                                                                 
    100 |   612635 |                    1 |            8 |              6 |                                 ->  XN Hash  (cost=7063797.76..7063797.76 rows=706379776 width=8)                                                                                                                                                                                                                                                                                                                |                                                                                                                                                                                                                                                                                                                                                                                                                 
    100 |   612635 |                    1 |            9 |              8 |                                       ->  XN Seq Scan on sales a  (cost=0.00..7063797.76 rows=706379776 width=8)                                                                                                                                                                                                                                                                                                 |                                                                                                                                                                                                                                                                                                                                                                                                                 
(9 rows)
```

# SYS\$1QUERY\$1HISTORY
<a name="SYS_QUERY_HISTORY"></a>

Use SYS\$1QUERY\$1HISTORY to view details of user queries. Each row represents a user query with accumulated statistics for some of the fields. This view contains many types of queries, such as data definition language (DDL), data manipulation language (DML), copy, unload, and Amazon Redshift Spectrum. It contains both running and finished queries.

SYS\$1QUERY\$1HISTORY 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).

**Note**  
To verify whether a transaction containing the executed query was successfully committed, you need to perform a join operation between system tables and the `sys_transaction_history` table. For example:  

```
SELECT 
    qh.transaction_id,
    qh.query_id,
    qh.status AS query_status,
    qh.query_type,
    TRIM(qh.query_text) AS query_text,
    th.status AS transaction_status
FROM 
    sys_query_history qh
LEFT JOIN 
    sys_transaction_history th ON qh.transaction_id = th.transaction_id;
```

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

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/redshift/latest/dg/SYS_QUERY_HISTORY.html)

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

The following query returns running and queued queries.

```
SELECT user_id,
       query_id,
       transaction_id,
       session_id,
       status,
       trim(database_name) AS database_name,
       start_time,
       end_time,
       result_cache_hit,
       elapsed_time,
       queue_time,
       execution_time
FROM sys_query_history
WHERE status IN ('running','queued')
ORDER BY start_time;
```

Sample output.

```
 user_id | query_id | transaction_id | session_id | status  | database_name |        start_time         |          end_time          | result_cache_hit | elapsed_time | queue_time | execution_time
---------+----------+----------------+------------+---------+---------------+---------------------------+----------------------------+------------------+--------------+------------+----------------
     101 |   760705 |         852337 | 1073832321 | running | tpcds_1t      | 2022-02-15 19:03:19.67849 | 2022-02-15 19:03:19.739811 | f                |        61321 |          0 |              0
```

The following query returns the query start time, end time, queue time, elapsed time, planning time, and other metadata for a specific query.

```
SELECT user_id,
       query_id,
       transaction_id,
       session_id,
       status,
       trim(database_name) AS database_name,
       start_time,
       end_time,
       result_cache_hit,
       elapsed_time,
       queue_time,
       execution_time,
       planning_time,
       trim(query_text) as query_text
FROM sys_query_history
WHERE query_id = 3093;
```

Sample output.

```
user_id | query_id | transaction_id | session_id |   status   | database_name |         start_time         |          end_time          | result_cache_hit | elapsed_time | queue_time | execution_time | planning_time | query_text
--------+----------+----------------+------------+------------+---------------+----------------------------+----------------------------+------------------+--------------+------------+----------------+---------------+-------------------------------------
    106 |     3093 |          11759 | 1073750146 | success    | dev           | 2023-03-16 16:53:17.840214 | 2023-03-16 16:53:18.106588 | f                |       266374 |          0 |         105725 |        136589 | select count(*) from item;
```

The following query lists the 10 most recent SELECT queries.

```
SELECT query_id,
       transaction_id,
       session_id,
       start_time,
       elapsed_time,
       queue_time,
       execution_time,
       returned_rows,
       returned_bytes
FROM sys_query_history
WHERE query_type = 'SELECT'
ORDER BY start_time DESC limit 10;
```

Sample output.

```
 query_id | transaction_id | session_id |         start_time         | elapsed_time | queue_time | execution_time | returned_rows | returned_bytes
----------+----------------+------------+----------------------------+--------------+------------+----------------+---------------+----------------
   526532 |          61093 | 1073840313 | 2022-02-09 04:43:24.149603 |       520571 |          0 |         481293 |             1 |           3794
   526520 |          60850 | 1073840313 | 2022-02-09 04:38:27.24875  |       635957 |          0 |         596601 |             1 |           3679
   526508 |          60803 | 1073840313 | 2022-02-09 04:37:51.118835 |       563882 |          0 |         503135 |             5 |          17216
   526505 |          60763 | 1073840313 | 2022-02-09 04:36:48.636224 |       649337 |          0 |         589823 |             1 |            652
   526478 |          60730 | 1073840313 | 2022-02-09 04:36:11.741471 |     14611321 |          0 |       14544058 |             0 |              0
   526467 |          60636 | 1073840313 | 2022-02-09 04:34:11.91463  |     16711367 |          0 |       16633767 |             1 |            575
   511617 |         617946 | 1074009948 | 2022-01-20 06:21:54.44481  |      9937090 |          0 |        9899271 |           100 |          12500
   511603 |         617941 | 1074259415 | 2022-01-20 06:21:45.71744  |      8065081 |          0 |        7582500 |           100 |           8889
   511595 |         617935 | 1074128320 | 2022-01-20 06:21:44.030876 |      1051270 |          0 |        1014879 |             1 |             72
   511584 |         617931 | 1074030019 | 2022-01-20 06:21:42.764088 |       609033 |          0 |         485887 |           100 |           8438
```

 The following query shows the daily select query count and average query elapsed time. 

```
SELECT date_trunc('day',start_time) AS exec_day,
       status,
       COUNT(*) AS query_cnt,
       AVG(datediff (microsecond,start_time,end_time)) AS elapsed_avg
FROM sys_query_history
WHERE query_type = 'SELECT'
AND start_time >= '2022-01-14'
AND start_time <= '2022-01-18'
GROUP BY exec_day,
         status
ORDER BY exec_day,
         status;
```

Sample output.

```
      exec_day       | status  | query_cnt | elapsed_avg
---------------------+---------+-----------+------------
 2022-01-14 00:00:00 | success |      5253 |  56608048
 2022-01-15 00:00:00 | success |      7004 |  56995017
 2022-01-16 00:00:00 | success |      5253 |  57016363
 2022-01-17 00:00:00 | success |      5309 |  55236784
 2022-01-18 00:00:00 | success |      8092 |  54355124
```

The following query shows the daily query elapsed time performance.

```
SELECT distinct date_trunc('day',start_time) AS exec_day,
       query_count.cnt AS query_count,
       Percentile_cont(0.5) within group(ORDER BY elapsed_time) OVER (PARTITION BY exec_day) AS P50_runtime,
       Percentile_cont(0.8) within group(ORDER BY elapsed_time) OVER (PARTITION BY exec_day) AS P80_runtime,
       Percentile_cont(0.9) within group(ORDER BY elapsed_time) OVER (PARTITION BY exec_day) AS P90_runtime,
       Percentile_cont(0.99) within group(ORDER BY elapsed_time) OVER (PARTITION BY exec_day) AS P99_runtime,
       Percentile_cont(1.0) within group(ORDER BY elapsed_time) OVER (PARTITION BY exec_day) AS max_runtime
FROM sys_query_history
LEFT JOIN (SELECT  date_trunc('day',start_time) AS day, count(*) cnt
           FROM sys_query_history
           WHERE query_type = 'SELECT'
           GROUP by 1) query_count
ON date_trunc('day',start_time) = query_count.day
WHERE query_type = 'SELECT'
ORDER BY exec_day;
```

Sample output.

```
      exec_day       | query_count | p50_runtime | p80_runtime | p90_runtime | p99_runtime  | max_runtime
---------------------+-------------+-------------+-------------+-------------+--------------+--------------
 2022-01-14 00:00:00 |        5253 |  16816922.0 |  69525096.0 | 158524917.8 | 486322477.52 | 1582078873.0
 2022-01-15 00:00:00 |        7004 |  15896130.5 |  71058707.0 | 164314568.9 | 500331542.07 | 1696344792.0
 2022-01-16 00:00:00 |        5253 |  15750451.0 |  72037082.2 | 159513733.4 | 480372059.24 | 1594793766.0
 2022-01-17 00:00:00 |        5309 |  15394513.0 |  68881393.2 | 160254700.0 | 493372245.84 | 1521758640.0
 2022-01-18 00:00:00 |        8092 |  15575286.5 |  68485955.4 | 154559572.5 | 463552685.39 | 1542783444.0
 2022-01-19 00:00:00 |        5860 |  16648747.0 |  72470482.6 | 166485138.2 | 492038228.67 | 1693483241.0
 2022-01-20 00:00:00 |        1751 |  15422072.0 |  69686381.0 | 162315385.0 | 497066615.00 | 1439319739.0
 2022-02-09 00:00:00 |          13 |   6382812.0 |  17616161.6 |  21197988.4 |  23021343.84 |   23168439.0
```

The following query shows the query type distribution.

```
SELECT query_type,
       COUNT(*) AS query_count
FROM sys_query_history
GROUP BY query_type
ORDER BY query_count DESC;
```

Sample output.

```
 query_type | query_count
------------+-------------
 UTILITY    |      134486
 SELECT     |       38537
 DDL        |        4832
 OTHER      |         768
 LOAD       |         768
 CTAS       |         748
 COMMAND    |          92
```

The following example shows the difference in query hash results between several queries. Observe the following queries:

```
CREATE TABLE test_table (col1 INT);

INSERT INTO test_table VALUES (1),(2);

SELECT * FROM test_table;

SELECT * FROM test_table;

SELECT col1 FROM test_table;

SELECT * FROM test_table WHERE col1=1;

SELECT * FROM test_table WHERE col1=2;

SELECT query_id, TRIM(user_query_hash) AS user_query_hash, TRIM(generic_query_hash) AS generic_query_hash, TRIM(query_text) AS text FROM sys_query_history ORDER BY start_time
DESC LIMIT 10;
```

Following is a sample output:

```
query_id | user_query_hash | generic_query_hash | text
---------+-----------------+--------------------+----------
24723049 | oPuFtjEPLTs=    | oPuFtjEPLTs=       | select query_id, trim(user_query_hash) as user_query_hash, trim(generic_query_hash) as generic_query_hash, query_hash_version, trim(query_text) as text from sys_query_history order by start_time\r\ndesc limit 20
24723045 | Gw2Kwdd8m2I=    | IwfRu8/XAKI=       | select * from test_table where col1=2 limit 100
24723041 | LNw2vx0GDXo=    | IwfRu8/XAKI=       | select * from test_table where col1=1 limit 100
24723036 | H+qep/c82Y8=    | H+qep/c82Y8=       | select col1 from test_table limit 100
24723033 | H+qep/c82Y8=    | H+qep/c82Y8=       | select * from test_table limit 100
24723029 | H+qep/c82Y8=    | H+qep/c82Y8=       | select * from test_table limit 100
24723023 | 50sirx9E1hU=    | uO36Z1a/QYs=       | insert into test_table values (1),(2)
24723021 | YSVnlivZHeo=    | YSVnlivZHeo=       | create table test_table (col1 int)
```

`SELECT * FROM test_table;` and `SELECT col1 FROM test_table;` have the same user\$1query\$1hash value, since test\$1table has only one column. `SELECT * FROM test_table WHERE col1=1;` and `SELECT * FROM test_table WHERE col1=2;` have different user\$1query\$1hash values, but identical generic\$1query\$1hash values, since the two queries are identical outside of the query literals 1 and 2.

# SYS\$1QUERY\$1TEXT
<a name="SYS_QUERY_TEXT"></a>

Use SYS\$1QUERY\$1TEXT to view the query text of all queries. Each row represents the query text of queries up to 4000 characters starting with sequence number 0. When the query statement contains more than 4000 characters, additional rows are logged for the statement by incrementing the sequence number for each row. This view logs all user query text such as DDL, utility, Amazon Redshift queries, and leader-node only queries.

SYS\$1QUERY\$1TEXT 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).

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

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/redshift/latest/dg/SYS_QUERY_TEXT.html)

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

The following query returns running and queued queries.

```
SELECT user_id, 
 query_id, 
 transaction_id, 
 session_id, start_time, 
 sequence, trim(text) as text from sys_query_text 
 ORDER BY sequence;
```

Sample output.

```
 user_id | query_id | transaction_id | session_id |        start_time          | sequence |                                                        text
--------+----------+-----------------+------------+----------------------------+----------+----------------------------------------------------------------------------------------------------------------------
   100  |     4    |       1396      | 1073750220 | 2023-04-28 16:44:55.887184 |     0    | SELECT trim(text) as text, sequence FROM sys_query_text WHERE query_id = pg_last_query_id() AND user_id > 1 AND start
_time > '2023-04-28 16:44:55.922705+00:00'::timestamp order by sequence;
```

The following query returns the permissions that have been granted or revoked from groups in your database.

```
SELECT 
    SPLIT_PART(text, ' ', 1) as grantrevoke, 
    SPLIT_PART((SUBSTRING(text, STRPOS(UPPER(text), 'GROUP'))), ' ', 2) as group, 
    SPLIT_PART((SUBSTRING(text, STRPOS(UPPER(text), ' '))), 'ON', 1) as type, 
    SPLIT_PART((SUBSTRING(text, STRPOS(UPPER(text), 'ON'))), ' ', 2) || ' ' || SPLIT_PART((SUBSTRING(text, STRPOS(UPPER(text), 'ON'))), ' ', 3) as entity 
FROM SYS_QUERY_TEXT 
WHERE (text LIKE 'GRANT%' OR text LIKE 'REVOKE%') AND text LIKE '%GROUP%';
         
+-------------+----------+--------+----------+
| grantrevoke |  group   |  type  |  entity  |
+-------------+----------+--------+----------+
| GRANT       | bi_group | SELECT | TABLE t1 |
| GRANT       | bi_group | SELECT | TABLE t1 |
| GRANT       | bi_group | SELECT | TABLE t1 |
| GRANT       | bi_group | USAGE  | TABLE t1 |
| GRANT       | bi_group | SELECT | TABLE t1 |
| GRANT       | bi_group | SELECT | TABLE t1 |
+-------------+----------+--------+----------+
```

# SYS\$1REDSHIFT\$1TEMPLATE
<a name="SYS_REDSHIFT_TEMPLATE"></a>

Use SYS\$1REDSHIFT\$1TEMPLATE to view details of Redshift TEMPLATES.

This view contains the TEMPLATES that have been created.

SYS\$1REDSHIFT\$1TEMPLATE 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).

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

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/redshift/latest/dg/SYS_REDSHIFT_TEMPLATE.html)

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

The following query returns all templates visible to the current user:

```
SELECT * FROM SYS_REDSHIFT_TEMPLATE;
```

Sample output.

```
 database_name | schema_name |   template_name    | template_type |        create_time         |     last_modified_time     | owner_id | last_modified_by | template_parameters
---------------+-------------+--------------------+---------------+----------------------------+----------------------------+----------+------------------+---------------------
 dev           | s1          | shapefile_template |             1 | 2025-12-17 22:42:02.079758 | 2025-12-17 22:42:02.079758 |      101 |              101 | {
    "SIMPLIFY_AUTO": 0.000001,
    "SHAPEFILE": 1,
    "COMPRESSION_UPDATE": 0
}
 dev           | s2          | orc_template       |             1 | 2025-12-17 22:42:23.582815 | 2025-12-17 22:42:23.582815 |      101 |              101 | {
    "ORC": "serializetojson_default"
}
 dev           | s1          | csv_template       |             1 | 2025-12-17 22:43:01.822361 | 2025-12-17 22:43:01.822361 |      101 |              101 | {
    "ENCRYPTED": 1,
    "CSV": 1,
    "ENCODING": 1,
    "DELIMITER": ","
}
(3 rows)
```

# SYS\$1RESTORE\$1LOG
<a name="SYS_RESTORE_LOG"></a>

Use SYS\$1RESTORE\$1LOG to monitor the migration progress of each table in the cluster during a classic resize to RA3 nodes. It captures the historic throughput of data migration during the resize operation. For more information about classic resize to RA3 nodes, see [Classic resize](https://docs.aws.amazon.com/redshift/latest/mgmt/managing-cluster-operations.html#classic-resize-faster). 

SYS\$1RESTORE\$1LOG is visible only to superusers.

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

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/redshift/latest/dg/SYS_RESTORE_LOG.html)

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

The following query calculates the throughput of data processing, using SYS\$1RESTORE\$1LOG.

```
SELECT
    ROUND(sum(delta_data_processed) / 1024.0, 2) as data_processed_gb,
    ROUND(datediff(sec, min(event_time), max(event_time)) / 3600.0, 2) as duration_hr,
    ROUND(data_processed_gb/duration_hr, 2) as throughput_gb_per_hr
from sys_restore_log;
```

Sample output.

```
 data_processed_gb | duration_hr | throughput_gb_per_hr 
-------------------+-------------+----------------------
              0.91 |        8.37 |                 0.11
(1 row)
```

The following query that shows all redistribution types.

```
SELECT * from sys_restore_log ORDER BY event_time;
```

```
 database_name |     schema_name      |      table_name      | table_id |          action             | total_data_processed | delta_data_processed |         event_time         | table_size | message |   redistribution_type    
---------------+----------------------+----------------------+----------+-----------------------------+----------------------+----------------------+----------------------------+------------+---------+--------------------------
 dev           | schemaaaa877096d844d | customer_key         |   106424 | Redistribution started      |                    0 |                      | 2024-01-05 02:18:00.744977 |        325 |         | Restore Distkey Table
 dev           | schemaaaa877096d844d | dp30907_t2_autokey   |   106430 | Redistribution started      |                    0 |                      | 2024-01-05 02:18:02.756675 |         90 |         | Restore Distkey Table
 dev           | schemaaaa877096d844d | dp30907_t2_autokey   |   106430 | Redistribution completed    |                   90 |                   90 | 2024-01-05 02:23:30.643718 |         90 |         | Restore Distkey Table
 dev           | schemaaaa877096d844d | customer_key         |   106424 | Redistribution completed    |                  325 |                  325 | 2024-01-05 02:23:45.998249 |        325 |         | Restore Distkey Table
 dev           | schemaaaa877096d844d | dp30907_t1_even      |   106428 | Redistribution started      |                    0 |                      | 2024-01-05 02:23:46.083849 |         30 |         | Rebalance Disteven Table
 dev           | schemaaaa877096d844d | dp30907_t5_auto_even |   106436 | Redistribution started      |                    0 |                      | 2024-01-05 02:23:46.855728 |         45 |         | Rebalance Disteven Table
 dev           | schemaaaa877096d844d | dp30907_t5_auto_even |   106436 | Redistribution completed    |                   45 |                   45 | 2024-01-05 02:24:16.343029 |         45 |         | Rebalance Disteven Table
 dev           | schemaaaa877096d844d | dp30907_t1_even      |   106428 | Redistribution completed    |                   30 |                   30 | 2024-01-05 02:24:20.584703 |         30 |         | Rebalance Disteven Table
 dev           | schemaefd028a2a48a4c | customer_even        |   130512 | Redistribution started      |                    0 |                      | 2024-01-05 04:54:55.641741 |        190 |         | Restore Disteven Table
 dev           | schemaefd028a2a48a4c | customer_even        |   130512 | Redistribution checkpointed |     29.4342113157737 |     29.4342113157737 | 2024-01-05 04:55:04.770696 |        190 |         | Restore Disteven Table
(8 rows)
```

# SYS\$1RESTORE\$1STATE
<a name="SYS_RESTORE_STATE"></a>

Use SYS\$1RESTORE\$1STATE to monitor the migration progress of each table during a classic resize. This is specifically applicable when the target node type is RA3. For more information about classic resize to RA3 nodes, see [Classic resize](https://docs.aws.amazon.com/redshift/latest/mgmt/managing-cluster-operations.html#classic-resize-faster).

SYS\$1RESTORE\$1STATE is visible only to superusers. For more information, see [Visibility of data in system tables and views](cm_chap_system-tables.md#c_visibility-of-data).

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

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/redshift/latest/dg/SYS_RESTORE_STATE.html)

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

The following query returns records for running and queued queries.

```
SELECT * FROM sys_restore_state;
```

Sample output.

```
 userid | database_name | schema_id | table_id |   table_name   | redistribution_status | precentage_redistributed |   redistribution_type
--------+---------------+-----------+----------+----------------+-----------------------+--------------------------+-------------------------
    1   |     test1     |   124865  |  124878  | customer_key_4 |         Pending       |      0                   |  Rebalance Disteven Table
    1   |      dev      |   124865  |  124874  | customer_key_3 |         Pending       |      0                   |  Rebalance Disteven Table
    1   |      dev      |   124865  |  124870  | customer_key_2 |        Completed      |     100                  |  Rebalance Disteven Table
    1   |      dev      |   124865  |  124866  | customer_key_1 |       In progress     |     13.52                |  Restore Distkey Table
```

The following gives you the data-processing status.

```
SELECT
    redistribution_status, ROUND(SUM(block_count) / 1024.0, 2) AS total_size_gb
FROM sys_restore_state sys inner join stv_tbl_perm stv
    on sys.table_id = stv.id
GROUP BY sys.redistribution_status;
```

Sample output.

```
 redistribution_status | total_size_gb 
-----------------------+---------------
 Completed             |          0.07
 Pending               |          0.71
 In progress           |          0.20
(3 rows)
```

# SYS\$1SCHEMA\$1QUOTA\$1VIOLATIONS
<a name="r_SYS_SCHEMA_QUOTA_VIOLATIONS"></a>

Records the occurrence, transaction ID, and other useful information when a schema quota is exceeded. This system table is a translation of [STL\$1SCHEMA\$1QUOTA\$1VIOLATIONS](r_STL_SCHEMA_QUOTA_VIOLATIONS.md).

r\$1SYS\$1SCHEMA\$1QUOTA\$1VIOLATIONS 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).

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

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/redshift/latest/dg/r_SYS_SCHEMA_QUOTA_VIOLATIONS.html)

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

The following query shows the result of a quota violation:

```
SELECT user_id, TRIM(schema_name) "schema_name", quota, disk_usage, record_time FROM
sys_schema_quota_violations WHERE SCHEMA_NAME = 'sales_schema' ORDER BY timestamp DESC;
```

This query returns the following sample output for the specified schema:

```
user_id| schema_name  | quota | disk_usage | record_time
-------+--------------+-------+------------+----------------------------
104    | sales_schema | 2048  | 2798       | 2020-04-20 20:09:25.494723
(1 row)
```

# SYS\$1SERVERLESS\$1USAGE
<a name="SYS_SERVERLESS_USAGE"></a>

Use SYS\$1SERVERLESS\$1USAGE to view details of Amazon Redshift Serverless usage of resources. This system view doesn't apply to provisioned Amazon Redshift clusters.

This view contains the serverless usage summary including how much compute capacity is used to process queries and the amount of Amazon Redshift managed storage used at a 1-minute granularity. The compute capacity is measured in Redshift processing units (RPUs) and metered for the workloads that you run in RPU-seconds on a per-second basis. RPUs are used to process queries on the data loaded in the data warehouse, queried from an Amazon S3 data lake, or accessed from operational databases using a federated query. Amazon Redshift Serverless retains the information in SYS\$1SERVERLESS\$1USAGE for 7 days.

For examples on compute cost billing, see [Billing for Amazon Redshift Serverless](https://docs.aws.amazon.com/redshift/latest/mgmt/serverless-billing.html).

SYS\$1SERVERLESS\$1USAGE is visible only to superusers. For more information, see [Visibility of data in system tables and views](cm_chap_system-tables.md#c_visibility-of-data).

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

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/redshift/latest/dg/SYS_SERVERLESS_USAGE.html)

## Usage notes
<a name="SYS_SERVERLESS_USAGE-usage_notes"></a>
+  There are situations where compute\$1seconds is 0 but charged\$1seconds is greater than 0, or vice versa. This is normal behavior resulting from the way data is recorded in the system view. For a more accurate representation of serverless usage details, we recommend aggregating the data. 

## Example
<a name="SYS_SERVERLESS_USAGE-examples"></a>

To get the total charges for RPU hours used for a time interval by querying charged\$1seconds, run the following query:

```
select trunc(start_time) "Day", 
(sum(charged_seconds)/3600::double precision) * <Price for 1 RPU> as cost_incurred 
from sys_serverless_usage 
group by 1 
order by 1
```

Note that there can be idle time during the interval. Idle time doesn't add to RPUs consumed.

# SYS\$1SESSION\$1HISTORY
<a name="SYS_SESSION_HISTORY"></a>

Use the SYS\$1SESSION\$1HISTORY to view information about the current active sessions and session history. 

SYS\$1SESSION\$1HISTORY 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).

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

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/redshift/latest/dg/SYS_SESSION_HISTORY.html)

### Example
<a name="SYS_SESSION_HISTORY-examples"></a>

The following is a sample output of SYS\$1SESSION\$1HISTORY.

```
select * from sys_session_history;
 user_id | session_id |   database_name  | status | session_timeout |         start_time         |          end_time          
---------+------------+------------------+--------+-----------------+----------------------------+----------------------------
       1 | 1073971370 | dev              | closed |        0        | 2023-07-17 15:50:12.030104 | 2023-07-17 15:50:12.123218
       1 | 1073979694 | dev              | closed |        0        | 2023-07-17 15:50:24.117947 | 2023-07-17 15:50:24.131859
       1 | 1073873049 | dev              | closed |        0        | 2023-07-17 15:49:29.067398 | 2023-07-17 15:49:29.070294
       1 | 1073873086 | database18127a4a | closed |        0        | 2023-07-17 15:49:29.119018 | 2023-07-17 15:49:29.125925
       1 | 1073832112 | dev              | closed |        0        | 2023-07-17 15:49:29.164688 | 2023-07-17 15:49:29.179631
       1 | 1073987697 | dev              | closed |        0        | 2023-07-17 15:49:29.26749  | 2023-07-17 15:49:29.273034
       1 | 1073922429 | dev              | closed |        0        | 2023-07-17 15:49:33.35315  | 2023-07-17 15:49:33.367499
       1 | 1073766783 | dev              | closed |        0        | 2023-07-17 15:49:45.38237  | 2023-07-17 15:49:45.396902
       1 | 1073807506 | dev              | active |        0        | 2023-07-17 15:51:48        |
```

# SYS\$1SPATIAL\$1SIMPLIFY
<a name="SYS_SPATIAL_SIMPLIFY"></a>

You can query the system view SYS\$1SPATIAL\$1SIMPLIFY to get information about simplified spatial geometry objects using the COPY command. When you use COPY on a shapefile, you can specify SIMPLIFY `tolerance`, SIMPLIFY AUTO, and SIMPLIFY AUTO `max_tolerance` ingestion options. The result of the simplification is summarized in SYS\$1SPATIAL\$1SIMPLIFY system view. 

When SIMPLIFY AUTO `max_tolerance` is set, this view contains a row for each geometry that exceeded the maximum size. When SIMPLIFY `tolerance` is set, then one row for the entire COPY operation is stored. This row references the COPY query ID and the specified simplification tolerance.

For more information about loading a shapefile, see [Loading a shapefile into Amazon Redshift](spatial-copy-shapefile.md).

SYS\$1SPATIAL\$1SIMPLIFY 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).

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

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/redshift/latest/dg/SYS_SPATIAL_SIMPLIFY.html)

## Sample query
<a name="SYS_SPATIAL_SIMPLIFY-sample-query"></a>

The following query returns the list of records that COPY simplified. 

```
SELECT * FROM sys_spatial_simplify;
                
             
 query_id | line_number | maximum_tolerance | initial_size | simplified | final_size |   final_tolerance
----------+-------------+-------------------+--------------+------------+------------+----------------------
    20    |     1184704 |                -1 |      1513736 | t          |    1008808 |   1.276386653895e-05
    20    |     1664115 |                -1 |      1233456 | t          |    1023584 | 6.11707814796635e-06
```

# SYS\$1STREAM\$1SCAN\$1ERRORS
<a name="r_SYS_STREAM_SCAN_ERRORS"></a>

Records errors for records loaded via streaming ingestion.

SYS\$1STREAM\$1SCAN\$1ERRORS 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).

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

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/redshift/latest/dg/r_SYS_STREAM_SCAN_ERRORS.html)

# SYS\$1STREAM\$1SCAN\$1STATES
<a name="r_SYS_STREAM_SCAN_STATES"></a>

Records scan states for records loaded via streaming ingestion.

SYS\$1STREAM\$1SCAN\$1STATES 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).

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

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/redshift/latest/dg/r_SYS_STREAM_SCAN_STATES.html)

The following query shows stream and topic data for specific queries.

```
select query_id,mv_name::varchar,external_schema_name::varchar,stream_name::varchar,sum(scanned_rows) total_records,
sum(scanned_bytes) total_bytes from sys_stream_scan_states where query in (5401180,8601939) group by 1,2,3,4;

  query_id  |    mv_name     | external_schema_name |   stream_name   | total_records |  total_bytes
------------+----------------+----------------------+-----------------+---------------+----------------
 5401180    | kinesistest    | kinesis              | kinesisstream   |    1493255696 | 3209006490704
 8601939    | msktest        | msk                  | mskstream       |      14677023 |   31056580668
(2 rows)
```

# SYS\$1TRANSACTION\$1HISTORY
<a name="SYS_TRANSACTION_HISTORY"></a>

Use SYS\$1TRANSACTION\$1HISTORY to see details of a transaction when tracking a query.

SYS\$1TRANSACTION\$1HISTORY is visible only to superusers. For more information, see [Visibility of data in system tables and views](cm_chap_system-tables.md#c_visibility-of-data).

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

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/redshift/latest/dg/SYS_TRANSACTION_HISTORY.html)

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

```
select * from sys_transaction_history order by transaction_start_time desc;
                
 user_id | transaction_id | isolation_level |   status   |   transaction_start_time   |     commit_start_time      |      commit_end_time       | blocks_committed | undo_transaction_id 
---------+----------------+-----------------+------------+----------------------------+----------------------------+----------------------------+------------------+---------------------     
     100 |           1310 | Serializable    | committed  | 2023-08-27 21:03:11.822205 | 2023-08-28 21:03:11.825287 | 2023-08-28 21:03:11.854883 |               17 |                  -1
     101 |           1345 | Serializable    | committed  | 2023-08-27 21:03:12.000278 | 2023-08-28 21:03:12.003736 | 2023-08-28 21:03:12.030061 |               17 |                  -1
     102 |           1367 | Serializable    | committed  | 2023-08-27 21:03:12.1532   | 2023-08-28 21:03:12.156124 | 2023-08-28 21:03:12.186468 |               17 |                  -1
     100 |           1370 | Serializable    | committed  | 2023-08-27 21:03:12.199316 | 2023-08-28 21:03:12.204854 | 2023-08-28 21:03:12.238186 |               24 |                  -1
     100 |           1408 | Serializable    | committed  | 2023-08-27 21:03:53.891107 | 2023-08-28 21:03:53.894825 | 2023-08-28 21:03:53.927465 |               17 |                  -1
     100 |           1409 | Serializable    | rolledback | 2023-08-27 21:03:53.936431 | 2000-01-01 00:00:00        | 2023-08-28 21:04:08.712532 |                0 |                1409
     101 |           1415 | Serializable    | committed  | 2023-08-27 21:04:24.283188 | 2023-08-28 21:04:24.289196 | 2023-08-28 21:04:24.374318 |               25 |                  -1
     101 |           1416 | Serializable    | committed  | 2023-08-27 21:04:24.38818  | 2023-08-28 21:04:24.391688 | 2023-08-28 21:04:24.415135 |               17 |                  -1
     100 |           1417 | Serializable    | rolledback | 2023-08-27 21:04:24.424252 | 2000-01-01 00:00:00        | 2023-08-28 21:04:28.354826 |                0 |                1417
     101 |           1418 | Serializable    | rolledback | 2023-08-27 21:04:24.425195 | 2000-01-01 00:00:00        | 2023-08-28 21:04:28.680355 |                0 |                1418
     100 |           1420 | Serializable    | committed  | 2023-08-27 21:04:28.697607 | 2023-08-28 21:04:28.702374 | 2023-08-28 21:04:28.735541 |               23 |                  -1
     101 |           1421 | Serializable    | committed  | 2023-08-27 21:04:28.744854 | 2023-08-28 21:04:28.749344 | 2023-08-28 21:04:28.779029 |               23 |                  -1
     101 |           1423 | Serializable    | committed  | 2023-08-27 21:04:28.78942  | 2023-08-28 21:04:28.791556 | 2023-08-28 21:04:28.817485 |               16 |                  -1
     100 |           1430 | Serializable    | committed  | 2023-08-27 21:04:28.917788 | 2023-08-28 21:04:28.919993 | 2023-08-28 21:04:28.944812 |               16 |                  -1
     102 |           1494 | Serializable    | committed  | 2023-08-27 21:04:37.029058 | 2023-08-28 21:04:37.033137 | 2023-08-28 21:04:37.062001 |               16 |                  -1
```

# SYS\$1UDF\$1LOG
<a name="SYS_UDF_LOG"></a>

Records system-defined error and warning messages generated during user-defined function (UDF) execution. 

SYS\$1UDF\$1LOG is visible only to superusers. For more information, see [Visibility of data in system tables and views](cm_chap_system-tables.md#c_visibility-of-data).

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

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/redshift/latest/dg/SYS_UDF_LOG.html)

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

The following example shows how UDFs handle system-defined errors. The first block shows the definition for a UDF function that returns the inverse of an argument. When you run the function and provide a 0 as your argument, the function returns an error. The last statement returns the error message logged in SYS\$1UDF\$1LOG.

```
-- Create a function to find the inverse of a number.
CREATE OR REPLACE FUNCTION f_udf_inv(a int) 

RETURNS float 

IMMUTABLE AS $$return 1/a 

$$ LANGUAGE plpythonu; 

-- Run the function with 0 to create an error.
Select f_udf_inv(0); 

-- Query SYS_UDF_LOG to view the message.
Select query_id, record_time, message::varchar from sys_udf_log; 


query_id    |    record_time              |                 message
----------+----------------------------+-------------------------------------------------------
2211        | 2023-08-23 15:53:11.360538 |  ZeroDivisionError: integer division or modulo by zero line 2, in f_udf_inv\n return 1/a\n
```

The following example adds logging and a warning message to the UDF so that a divide by zero operation results in a warning message instead of stopping with an error message.

```
-- Create a function to find the inverse of a number and log a warning if you input 0.
CREATE OR REPLACE FUNCTION f_udf_inv_log(a int)
  RETURNS float IMMUTABLE
 AS $$ 
  import logging
  logger = logging.getLogger() #get root logger
  if a==0:
    logger.warning('You attempted to divide by zero.\nReturning zero instead of error.\n') 
    return 0
  else:
     return 1/a
$$ LANGUAGE plpythonu;

-- Run the function with 0 to trigger the warning.
Select f_udf_inv_log(0);

-- Query SYS_UDF_LOG to view the message.
Select query_id, record_time, message::varchar from sys_udf_log;

 query_id |        record_time         |                                    message
----------+----------------------------+-------------------------------------------------------------------------------
     0   | 2023-08-23 16:10:48.833503 | WARNING: You attempted to divide by zero.\nReturning zero instead of error.\n
```

# SYS\$1UNLOAD\$1DETAIL
<a name="SYS_UNLOAD_DETAIL"></a>

Use SYS\$1UNLOAD\$1DETAIL to view details of an UNLOAD operation. It records one row for each file created by an UNLOAD statement. For example, if an UNLOAD creates 12 files, SYS\$1UNLOAD\$1DETAIL will contain 12 corresponding rows.

SYS\$1UNLOAD\$1DETAIL 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).

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

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/redshift/latest/dg/SYS_UNLOAD_DETAIL.html)

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

The following query shows the unloaded query details, including format, rows, and file count of unload command.

```
select query_id, substring(file_name, 0, 50), transfer_size, file_format from sys_unload_detail;
```

Sample output.

```
 
 query_id |                     substring                               | transfer_size | file_format 
----------+-------------------------------------------------------------+---------------+-------------
     9272 | s3://amzn-s3-demo-bucket/my_unload_doc_venue0000_part_00.gz  |        395886 | Text      
     9272 | s3://amzn-s3-demo-bucket/my_unload_doc_venue0001_part_00.gz  |        406444 | Text      
     9272 | s3://amzn-s3-demo-bucket/my_unload_doc_venue0002_part_00.gz  |        409431 | Text      
     9272 | s3://amzn-s3-demo-bucket/my_unload_doc_venue0003_part_00.gz  |        403051 | Text      
     9272 | s3://amzn-s3-demo-bucket/my_unload_doc_venue0004_part_00.gz  |        413592 | Text      
     9272 | s3://amzn-s3-demo-bucket/my_unload_doc_venue0005_part_00.gz  |        395689 | Text      
(6 rows)
```

# SYS\$1UNLOAD\$1HISTORY
<a name="SYS_UNLOAD_HISTORY"></a>

Use SYS\$1UNLOAD\$1HISTORY to view details of UNLOAD commands. Each row represents a UNLOAD command with accumulated statistics for some of the fields. It contains both running and finished UNLOAD commands.

SYS\$1UNLOAD\$1HISTORY 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).

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

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/redshift/latest/dg/SYS_UNLOAD_HISTORY.html)

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

The following query shows the unloaded query details, including format, rows, and file count of unload command.

```
SELECT query_id,
       file_format,
       start_time,
       duration,
       unloaded_rows,
       unloaded_files_count
FROM sys_unload_history
ORDER BY query_id,
file_format limit 100;
```

Sample output.

```
 query_id | file_format |         start_time         | duration | unloaded_rows | unloaded_files_count
----------+-------------+----------------------------+----------+---------------+----------------------
   527067 | Text        | 2022-02-09 05:18:35.844452 |  5932478 |            10 |                    1
```

# SYS\$1USERLOG
<a name="SYS_USERLOG"></a>

Records details for the following changes to a database user:
+ Create user
+ Drop user
+ Alter user (rename)
+ Alter user (alter properties)

You can query this view to see information about serverless workgroups and provisioned clusters.

SYS\$1USERLOG is visible only to superusers. For more information, see [Visibility of data in system tables and views](cm_chap_system-tables.md#c_visibility-of-data).

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

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/redshift/latest/dg/SYS_USERLOG.html)

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

The following example performs four user actions, then queries the SYS\$1USERLOG view.

```
CREATE USER userlog1 password 'Userlog1';
ALTER USER userlog1 createdb createuser;
ALTER USER userlog1 rename  to userlog2;
DROP user userlog2;

SELECT user_id, user_name, original_user_name, action, has_create_db_privs, is_superuser from SYS_USERLOG order by record_time desc;
```

```
user_id |  user_name | original_user_name |  action | has_create_db_privs | is_superuser
--------+------------+--------------------+---------+---------------------+------------
    108 |  userlog2  |                    | drop    |                   1 |   1
    108 |  userlog2  |     userlog1       | rename  |                   1 |   1
    108 |  userlog1  |                    | alter   |                   1 |   1
    108 |  userlog1  |                    | create  |                   0 |   0
 (4 rows)
```

# SYS\$1VACUUM\$1HISTORY
<a name="SYS_VACUUM_HISTORY"></a>

Use SYS\$1VACUUM\$1HISTORY to view details of vacuum queries. For information on the VACUUM command, see [VACUUM](r_VACUUM_command.md).

SYS\$1VACUUM\$1HISTORY 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).

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

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/redshift/latest/dg/SYS_VACUUM_HISTORY.html)