Appearance
Using Query Tags
You can define labels, known as query tags, to track query activity. The labels are typically used to classify workloads into a group in the absence of other identifying criteria. You can create WLM rules that define conditions based on the presence of tags. For example, based on the presence of a tag when a query runs, the query can be directed to a specific resource pool.
To define query tags in the database at the session level, use the set ybd_query_tags
command. It's just an arbitrary string presented to the workload manager, without any special formatting. You can specify multiple items with semicolons or spaces or whatever you like. For example:
premdb=# set ybd_query_tags='premdb_query';
SET
To see the query tags that are currently available, use the SHOW
command:
premdb=> show ybd_query_tags;
ybd_query_tags
----------------
premdb_query
(1 row)
You can use an ALTER ROLE command to make query tags apply to all of a user's sessions. For example:
premdb=# alter role bobr set ybd_query_tags='adolf ran this query';
ALTER ROLE
All of the queries that this user runs are logged with this string. Therefore, WLM rule conditions and actions can be defined with reference to it.
Tags associated with query execution are logged in sys.log_query.