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.query
view has astate
column (instead ofstatus
insys.log_query
). Thestate
column values areplanning
,queued
,preparing
,running
,cancelling
,blocked
, orcomplete
. Ablocked
query is a query that is waiting for a lock to be granted on a table. - The
sys.query
view does not have anend_time
column.
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