Query Band Load Identification

Overview

GaussDB(DWS) implements load identification and intra-queue priority control based on query_band. It provides more flexible load identification methods and identifies load queues based on job types, application names, and script names. Users can flexibly configure query_band identification queues based on service scenarios. In addition, priority control of job delivery in the queue is implemented. In the future, priority control of resources in the queue will be gradually implemented.

Administrators can configure the queue associated with query_band and estimate the memory limit based on service scenarios and job types to implement more flexible load control and resource management and control. If query_band is not configured for the service or the user does not associate query_band with an action, the queue associated with the user and the priority in the queue is used by default.

Load Behaviors Supported by query_band

query_band is a session-level GUC parameter. It is a job identifier of the character data type. Its value can be any string. However, for easier differentiation and configuration, query_band only identifies key-value pairs. For example:

1
SET query_band='JobName=abc;AppName=test;UserName=user';

JobName=abc, AppName=test, and UserName=user are independent key-value pairs. Specifications of the query_band key-value pairs:

query_band is configured, and identifies load behaviors, using key-value pairs. The supported load behaviors are described in Table 1.

Table 1 Load behaviors supported by QUERY_BAND

Type

Behavior

Behavior Description

Workload management (workload)

Resource pool (respool)

query_band associated with a resource pool

Workload management (workload)

Priority

Priority in the queue

Order

Queue (respool)

Currently, this field is invalid and is used for future extension.

query_band query order

The "Type" is used to classify load behaviors. Different load behaviors may belong to a same type. For example, both "Resource pool" and a "Priority" belong to "Workload management". The "Behavior" indicates a load behavior associated with a query_band key-value pair. The "Behavior description" describes a specific load behavior. The "Order" in the "Type" is used to indicate the priority of the query_band load behavior identification. When a session has multiple query_band key-value pairs, the query_band key-value pair with a smaller order value is preferentially used to identify a load behavior. Each query_band key-value pair can have multiple associated load behaviors, while one load behavior can only have one associated key-value pair. The query_band load behavior is described as follows:

Application and Configuration of query_band

  • When all running jobs are canceled in batches or the maximum number of concurrent jobs in a queue is 1 and only one queue is running jobs, the CN may be triggered to automatically wake up jobs. As a result, jobs are not delivered by priority.

Examples

  1. Set the associated resource pool to p1, priority to rush, and order to 1 for query_band JobName to abc.

    1
    2
    3
    4
    5
    SELECT * FROM gs_wlm_set_queryband_action('JobName=abc','respool=p1;priority=rush',1);
    gs_wlm_set_queryband_action
    -----------------------------
     t
    (1 row)
    

  2. Change the associated resource pool to p2 for query_band JobName=abc.

    1
    2
    3
    4
    5
    SELECT * FROM gs_wlm_set_queryband_action('JobName=abc','respool=p2');
    gs_wlm_set_queryband_action
    -----------------------------
     t
    (1 row)
    

  3. Change the priority to high for query_band JobName=abc.

    1
    2
    3
    4
    5
    SELECT * FROM gs_wlm_set_queryband_action('JobName=abc','priority=high');
    gs_wlm_set_queryband_action
    -----------------------------
     t
    (1 row)
    

  4. Change the order to 3 for query_band JobName=abc.

    1
    2
    3
    4
    5
    SELECT * FROM gs_wlm_set_queryband_order('JobName=abc',3);
    gs_wlm_set_queryband_order
    -----------------------------
     t
    (1 row)
    

  5. Query the load behaviors associated with query_band.

    1
    2
    3
    4
    5
    SELECT * FROM pg_queryband_action;
        qband     | respool_id | respool | priority | qborder
    --------------+------------+---------+----------+---------
     JobName=abc  |      17119 | p2      | high     |       1
    (1 row)
    

  6. In query_band, set the priority of AppName=test to Low, associate the user with the resource pool, and use the default sequence.

    1
    2
    3
    4
    5
    SELECT * FROM gs_wlm_set_queryband_action('AppName=test','priority=low');
    gs_wlm_set_queryband_action
    -----------------------------
     t
    (1 row)
    

  7. Query the load behaviors associated with query_band.

    1
    2
    3
    4
    5
    6
    SELECT * FROM pg_queryband_action;
        qband     | respool_id | respool | priority | qborder
    --------------+------------+---------+----------+---------
     AppName=test |          0 | NULL    | low      |      -1
     JobName=abc  |      16754 | p2      | high     |       3
    (2 rows)
    

  8. In query_band, cancel all the workload behaviors associated with JobName=abc and set them to default behaviors.

    1
    2
    3
    4
    5
    6
    7
    SELECT * FROM gs_wlm_set_queryband_action('JobName=abc','respool=null;priority=medium',-1);
    NOTICE:  The respool of query_band(JobName=abc) will be removed.
    NOTICE:  The priority of query_band(JobName=abc) will be removed.
     gs_wlm_set_queryband_action
    -----------------------------
     t
    (1 row)
    

  9. Query the load behaviors associated with query_band.

    1
    2
    3
    4
    5
    SELECT * FROM pg_queryband_action;
        qband     | respool_id | respool | priority | qborder
    --------------+------------+---------+----------+---------
     AppName=test |          0 | NULL    | low      |      -1
    (1 row)