Appearance
sys.query
This view returns similar information about queries to the sys.log_query view, but for actively running queries or submitted but not yet executed queries. There are two main differences in these two views:
- The
sys.queryview has astatecolumn (instead ofstatusinsys.log_query). Thestatecolumn values areplanning,queued,preparing,running,cancelling,blocked, orcomplete. Ablockedquery is a query that is waiting for a lock to be granted on a table. - The
sys.queryview does not have anend_timecolumn.
User accounts only see the queries they submit. Superuser accounts see all queries.
The following query is repeated twice, returning different results as queries progress on the system:
yellowbrick_test=# select query_id, state, user_name, total_ms, substr(query_text,1,30) from sys.query;
query_id | state | user_name | total_ms | substr
----------+-----------+-----------+----------+----------------------------------
59643010 | preparing | ybd_test | 2853 | select count(distinct "i_brand
(1 row)
yellowbrick_test=# select query_id, state, user_name, total_ms, substr(query_text,1,30) from sys.query;
query_id | state | user_name | total_ms | substr
----------+---------+-----------+-----------------------------------------------
59644598 | running | ybd_test | 1747 | YBULKLOAD INTO "yellowbrick_te
(1 row)Parent topic:System Views