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. See the sys.log_query page for column descriptions.
Note: The sys.query
view has a blocked
column. When a query is blocked, this column shows the reason. The sys.log_query
view does not have this column. All other columns in these two views are the same.
User accounts only see the queries they submit. Superuser accounts see all queries.
Examples
The following UPDATE
query is repeated every second, returning different results as queries progress on the system:
premdb=> select query_id, username, application_name, type, state, substr(query_text,1,25) qrytxt, parse_ms, plan_ms, assemble_ms, compile_ms, run_ms, client_ms, total_ms
from sys.query where type='update' and username='bobr'
order by 1 desc;
...
Watch every 1s Thu Sep 10 18:52:16 2020
query_id | username | application_name | type | state | qrytxt | parse_ms | plan_ms | assemble_ms | compile_ms | run_ms | client_ms | total_ms
----------+----------+------------------+--------+---------+---------------------------+----------+---------+-------------+------------+--------+-----------+----------
1141949 | bobr | ybsql | update | compile | update newmatchstats set | 0.528 | 2.475 | 27.465 | 513.597 | | | 544.672
(1 row)
Watch every 1s Thu Sep 10 18:52:17 2020
query_id | username | application_name | type | state | qrytxt | parse_ms | plan_ms | assemble_ms | compile_ms | run_ms | client_ms | total_ms
----------+----------+------------------+--------+-------+---------------------------+----------+---------+-------------+------------+---------+-----------+----------
1141949 | bobr | ybsql | update | run | update newmatchstats set | 0.528 | 2.475 | 27.465 | 1319.912 | 208.934 | | 1561.143
(1 row)
Watch every 1s Thu Sep 10 18:52:18 2020
query_id | username | application_name | type | state | qrytxt | parse_ms | plan_ms | assemble_ms | compile_ms | run_ms | client_ms | total_ms
----------+----------+------------------+--------+-------+---------------------------+----------+---------+-------------+------------+----------+-----------+----------
1141949 | bobr | ybsql | update | run | update newmatchstats set | 0.528 | 2.475 | 27.465 | 1319.912 | 1234.473 | | 2586.683
(1 row)
...