Skip to content

Using Query Tags

You can define labels, known as query tags, to track query activity. You can create WLM rules that define conditions based on the presence of tags, and you can log query tags as actions for rules. 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. 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='bobr 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.

Parent topic:How WLM Works