Amazon Redshift
Database Developer Guide
AWS services or capabilities described in AWS documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with AWS services in China.

STV_WLM_QUERY_STATE

Records the current state of queries being tracked by WLM.

STV_WLM_QUERY_STATE 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.

Table Columns

Column Name Data Type Description
xid integer Transaction ID of the query or subquery.
task integer ID used to track a query through the workload manager. Can be associated with multiple query IDs. If a query is restarted, the query is assigned a new query ID but not a new task ID.
query integer Query ID. If a query is restarted, the query is assigned a new query ID but not a new task ID.
service_class integer ID for the service class. For a list of service class IDs, see WLM Service Class IDs.
slot_count integer Number of WLM query slots.
wlm_start_time timestamp Time that the query entered the system table queue or short query queue.
state character(16) Current state of the query or subquery.

Possible values are:

  • Classified

  • Completed

  • Dequeued

  • Evicted

  • Evicting

  • Initialized

  • Invalid

  • Queued

  • QueuedWaiting

  • Rejected

  • Returning

  • Running

  • TaskAssigned

queue_time bigint Number of microseconds that the query has spent in the queue.
exec_time bigint Number of microseconds that the query has been executing.
query_priority char(20) The priority of the query. Possible values are n/a, lowest, low, normal, high, and highest, where n/a means that query priority isn't supported.

Sample Query

The following query displays all currently executing queries in service classes greater than 4. For a list of service class IDs, see WLM Service Class IDs.

select xid, query, trim(state), queue_time, exec_time from stv_wlm_query_state where service_class > 4;

This query returns the following sample output:

xid | query | btrim | queue_time | exec_time -------+-------+---------+------------+----------- 100813 | 25942 | Running | 0 | 1369029 100074 | 25775 | Running | 0 | 2221589242

On this page: