Skip to content

Rule Conditions

Rules consist of one or more conditions. When satisfied, these conditions trigger rule actions. You can define different kinds of conditions in Yellowbrick Manager by selecting directly from drop-down lists or by using filter operators. The following table describes these operators.

Filter OperatorDescriptionExamples
Is True, Not TrueBoolean conditionQuery is/is not a Single Worker query
Equals, Not EqualsSimple equality conditionSchema does not equal public; Application equals ybsql
Greater Than, Less Than> or <Cost >10000
Greater Than or Equal To, Less Than or Equal To>= or <=Memory Usage Estimate <=100
Contains String, Not Contains StringSimple substring operationsSQL contains union all; User Name does not contain bob
Matches, Not MatchesRegular expression (regex) pattern matching. Escaping is applied only when items are selected from a drop-down list. Regular expression validation is applied when entries are typed; warnings are displayed.SQL matches sys\.const; SQL matches sum\(substr
Matches Ignore Case, Not Matches Ignore CasePattern matching as above, but with respect to case

The following table lists the specific rule conditions that you can set up, shows which rule types support each condition, and lists the accepted values for each condition.

Filter ConditionDescriptionRule TypesAccepted Values
ApplicationApplication name, as sent by the application itself, or as defined for a session with a SQL SET command: set application_name <name>;All typesAny string that does or does not match an application name, such as ybsql or ym. Note that ybload application names have the version appended, so you cannot filter on the exact string 'ybload'.
Average CPU UsageYou can use Query Details > Statistics > RESOURCES (or UTILIZATION) in Yellowbrick Manager to find this value for past executions of a query. Alternatively, you can query the sys.log_query view.Runtime, CompletionAny percentage value
Bytes NetworkBytes moved internally over the network on the cluster (manager node to workers and vice versa). This number does not include data being returned to the client.Use Query Details > Statistics > RESOURCES in Yellowbrick Manager to find this value for past executions of a query.

Runtime, CompletionPositive whole numbers
Bytes ReadUse Query Details > Statistics > RESOURCES in Yellowbrick Manager to find this value for past executions of a query. Alternatively, select io_read_bytes from sys.log_query.Runtime, CompletionPositive whole numbers
Bytes WrittenUse Query Details > Statistics > RESOURCES in Yellowbrick Manager to find this value for past executions of a query. Alternatively, select io_write_bytes from sys.log_query.Runtime, CompletionPositive whole numbers
CommandFilter on a SQL command: select, update, insert, delete, or utility.Assemble, Compile, Restart, Runtime, CompletionSelect from the drop-down list. Filter on utility for CREATE TABLE commands. Note: You can define rules for INSERT INTO...SELECT statements but not for INSERT INTO...VALUES statements. INSERT INTO...VALUES operations are not executed by the backend database.

CostA relative value that is set by the planner.Compile, Restart, Runtime, CompletionAny number
DatabaseDatabase nameAll typesSelect from the drop-down list.
Error CodeYellowbrick error code; see Error Codes and Recoverable Error Codes.Restart, Runtime, CompletionA string that matches or does not match a specific error code.
Error MessageError message text.Restart, Runtime, CompletionAny string
Execution Duration (in ms)Number of milliseconds the query spent during execution on the worker nodes.Runtime, CompletionAny number
Hostname/IP AddressName or IP address of client machineAll typesAny string
Max Memory (in bytes)Maximum runtime memory. Use Query Details > Statistics > RESOURCES in Yellowbrick Manager to find this value for past executions of a query.Runtime, CompletionAny number
Memory Estimate (in MB)Estimated runtime memory. Use Query Details > Statistics > RESOURCES in Yellowbrick Manager to find this value for past executions of a query. Alternatively, select memory_estimated_bytes from sys.log_query.Compile, Restart, Runtime, CompletionAny number
Memory Estimate ConfidenceEstimated degree of confidence in the memory estimate value.Compile, Restart, Runtime, CompletionUnknown, None, Low, High
PriorityThe CPU priority of queries starts at Normal and is only settable by rules. Priority is not an attribute of a profile or pool. Based on a condition, you can trigger an action to set the priority to a lower (Low) or a higher (High or Critical) priority. Priority settings are only meaningful when multiple queries are running concurrently. If only one query is running, it is allocated 100% of the available CPU, regardless of its priority. When queries are running concurrently, the percentage of CPU time increases 2-3x by priority level. For example, if you have concurrent queries set to Low and Normal, the Normal query takes approximately 75% of the CPU time, and the Low query approximately 25% (the remainder).All typesLow, Normal, High, Critical
Query StateCurrent state of the query. See How Queries Are Executed for details about query states.All typesAny string
Query TagsUse query tags to classify queries, then take actions. (You can also set a tag as an action). See Using Query Tags.All typesAny string
Query is MovableThe query may be moved to another resource pool (and continue its execution there or be restarted there). See Moving Queries.All types except CompletionSelect a pool from the drop-down list.
Query is RestartableThe query may be restarted in another resource pool. See Restarting QueriesAll types except CompletionIs True, Not True
Referenced TablesName of a table that is referenced somewhere in a query.Compile, Runtime, CompletionContains or Not Contains <table_name> (select from list)
Resource PoolName of a WLM resource pool. See Setting and Matching Resource Pools in WLM Rules.All typesSelect a pool from the drop-down list.
Rows DeletedNumber of rows deleted by a DELETE operation.Runtime, CompletionAny number
Rows InsertedNumber of rows inserted by an INSERT operation.Runtime, CompletionAny number
Rows ReturnedNumber of rows returned to the client application.Runtime, CompletionAny number
SQLAny piece of SQL text that may be found in a query. You can also use this condition to check for a comment placed in a query, rather than filter on the SQL itself.All typesAny string
SchemaName of a schema.Assemble, Compile, Runtime, CompletionSelect from the drop-down list. The search_path for the current session determines whether the condition applies. If a named schema is in the search_path, that is a match.
Single WorkerQueries that only involve replicated tables are marked as “single worker” queries.Compile, Runtime, CompletionIs True, Not True
Temporary Bytes ReadNumber of bytes read from disk because spilling occurs during the query. Select io_spill_read_bytes from sys.log_query to find this value for past executions of a query.Runtime, CompletionAny number
Temporary Bytes WrittenNumber of bytes written to disk because spilling occurs during the query. Select io_spill_write_bytes from sys.log_query to find this value for past executions of a query.Runtime, CompletionAny number
Total Duration (in ms)The total time a query took to run (end time - submit time). This includes planning, compilation, and queue time. Use Query Details > Statistics > TIMING in Yellowbrick Manager to find this value for past executions of a query. Alternatively, select total_ms from sys.log_query.Runtime, CompletionAny number
Total Memory (in bytes)The total amount of memory used across the cluster to run the query. Use Query Details > Statistics > UTILIZATION in Yellowbrick Manager to find this value for past executions of a query. Alternatively, select memory_total_bytes from sys.log_query.Runtime, CompletionAny number
TypeType of administration operation, such as create, delete, drop, backup, restore, analyze, and ycopy. These values correspond to the type values in the sys.query and sys.log_query views.Assemble, Compile, Runtime, CompletionSelect from the drop-down list.Note: You can define rules for INSERT INTO...SELECT statements but not for INSERT INTO...VALUES statements. INSERT INTO...VALUES operations are not executed by the backend database. See also Managing the Row Store.

User NameDatabase user nameAll typesSelect from the drop-down list.
User RolesDatabase roles (in which a user has membership)All typesSelect from the drop-down list.

Parent topic:Creating WLM Rules