As per documentation,
To determine what queries are currently running against the database, type the following query:
select user_name, db_name, pid, query
from stv_recents
where status = 'Running';
Also, as per documentation,
To view all active queries currently running on the database, type the following query:
select * from stv_inflight;
However, i have observed that the two resultset doesn't match sometime. Right now, there were some SELECT queries which were aborted from the client and are not showing in the stv_inflight table but they are being shown in the stv_recents table with a Running status.
Can anybody explain why this is happening?
P.S. The queries involves user defined table.
From the documentation on the Redshift System Tables and Views,
STV views are virtual views that contain snapshots of the current system data. They are based on transient in-memory data and are not persisted to disk-based logs or regular tables.
Further, the documentation explains with the following contradictory example.
the following query against a system table might well return rows
select * from stv_exec_state
where currenttime > (select max(currenttime) from stv_exec_state)
So, over all if you are running queries against STV tables, the responses that you get will be based on the instantaneous state of the in-memory system data structures, and the responses of two subsequent queries may very well be not correlatable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With