Menu
Amazon Redshift
Database Developer Guide (API Version 2012-12-01)

STV_INFLIGHT

Use the STV_INFLIGHT table to determine what queries are currently running on the cluster. STV_INFLIGHT does not show leader-node only queries. For more information, see Leader Node–Only Functions.

STV_INFLIGHT 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
userid integer ID of user who generated entry.
slice integer Slice where the query is running.
query integer Query ID. Can be used to join various other system tables and views.
label character(30) Either the name of the file used to run the query or a label defined with a SET QUERY_GROUP command. If the query is not file-based or the QUERY_GROUP parameter is not set, this field is blank.
xid bigint Transaction ID.
pid integer Process ID. All of the queries in a session are run in the same process, so this value remains constant if you run a series of queries in the same session. You can use this column to join to the STL_ERROR table.
starttime timestamp Time that the query started.
text character(100) Query text, truncated to 100 characters if the statement exceeds that limit.
suspended integer Whether the query is suspended or not. 0 = false; 1 = true.
insert_pristine integer Whether write queries are/were able to run while the current query is/was running. 1 = no write queries allowed. 0 = write queries allowed. This column is intended for use in debugging.

Sample Queries

To view all active queries currently running on the database, type the following query:

Copy
select * from stv_inflight;

The sample output below shows two queries currently running, including the STV_INFLIGHT query itself and a query that was run from a script called avgwait.sql:

Copy
select slice, query, trim(label) querylabel, pid, starttime, substring(text,1,20) querytext from stv_inflight; slice|query|querylabel | pid | starttime | querytext -----+-----+-----------+-----+--------------------------+-------------------- 1011 | 21 | | 646 |2012-01-26 13:23:15.645503|select slice, query, 1011 | 20 |avgwait.sql| 499 |2012-01-26 13:23:14.159912|select avg(datediff( (2 rows)