<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h3 class="title">
      <a name="resource-groups">
      </a>
      7.1.16 Resource Groups
     </h3>
    </div>
   </div>
  </div>
  <a class="indexterm" name="idm46045260278160">
  </a>
  <p>
   MySQL supports creation and management of resource groups, and
      permits assigning threads running within the server to particular
      groups so that threads execute according to the resources
      available to the group. Group attributes enable control over its
      resources, to enable or restrict resource consumption by threads
      in the group. DBAs can modify these attributes as appropriate for
      different workloads.
  </p>
  <p>
   Currently, CPU time is a manageable resource, represented by the
      concept of
   <span class="quote">
    “
    <span class="quote">
     virtual CPU
    </span>
    ”
   </span>
   as a term that includes CPU
      cores, hyperthreads, hardware threads, and so forth. The server
      determines at startup how many virtual CPUs are available, and
      database administrators with appropriate privileges can associate
      these CPUs with resource groups and assign threads to groups.
  </p>
  <p>
   For example, to manage execution of batch jobs that need not
      execute with high priority, a DBA can create a
   <code class="literal">
    Batch
   </code>
   resource group, and adjust its priority
      up or down depending on how busy the server is. (Perhaps batch
      jobs assigned to the group should run at lower priority during the
      day and at higher priority during the night.) The DBA can also
      adjust the set of CPUs available to the group. Groups can be
      enabled or disabled to control whether threads are assignable to
      them.
  </p>
  <p>
   The following sections describe aspects of resource group use in
      MySQL:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      <a class="xref" href="resource-groups.html#resource-group-elements" title="Resource Group Elements">
       Resource Group Elements
      </a>
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="xref" href="resource-groups.html#resource-group-attributes" title="Resource Group Attributes">
       Resource Group Attributes
      </a>
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="xref" href="resource-groups.html#resource-group-management" title="Resource Group Management">
       Resource Group Management
      </a>
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="xref" href="resource-groups.html#resource-group-replication" title="Resource Group Replication">
       Resource Group Replication
      </a>
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="xref" href="resource-groups.html#resource-group-restrictions" title="Resource Group Restrictions">
       Resource Group Restrictions
      </a>
     </p>
    </li>
   </ul>
  </div>
  <div class="important" style="margin-left: 0.5in; margin-right: 0.5in;">
   <div class="admon-title">
    Important
   </div>
   <p>
    On some platforms or MySQL server configurations, resource
        groups are unavailable or have limitations. In particular, Linux
        systems might require a manual step for some installation
        methods. For details, see
    <a class="xref" href="resource-groups.html#resource-group-restrictions" title="Resource Group Restrictions">
     Resource Group Restrictions
    </a>
    .
   </p>
  </div>
  <div class="simplesect">
   <div class="titlepage">
    <div>
     <div class="simple">
      <h4 class="title">
       <a name="resource-group-elements">
       </a>
       Resource Group Elements
      </h4>
     </div>
    </div>
   </div>
   <p>
    These capabilities provide the SQL interface for resource group
        management in MySQL:
   </p>
   <div class="itemizedlist">
    <ul class="itemizedlist" style="list-style-type: disc; ">
     <li class="listitem">
      <p>
       SQL statements enable creating, altering, and dropping
            resource groups, and enable assigning threads to resource
            groups. An optimizer hint enables assigning individual
            statements to resource groups.
      </p>
     </li>
     <li class="listitem">
      <p>
       Resource group privileges provide control over which users
            can perform resource group operations.
      </p>
     </li>
     <li class="listitem">
      <p>
       The Information Schema
       <a class="link" href="information-schema-resource-groups-table.html" title="28.3.26 The INFORMATION_SCHEMA RESOURCE_GROUPS Table">
        <code class="literal">
         RESOURCE_GROUPS
        </code>
       </a>
       table exposes
            information about resource group definitions and the
            Performance Schema
       <a class="link" href="performance-schema-threads-table.html" title="29.12.22.8 The threads Table">
        <code class="literal">
         threads
        </code>
       </a>
       table shows the resource group assignment for each thread.
      </p>
     </li>
     <li class="listitem">
      <p>
       Status variables provide execution counts for each
            management SQL statement.
      </p>
     </li>
    </ul>
   </div>
  </div>
  <div class="simplesect">
   <div class="titlepage">
    <div>
     <div class="simple">
      <h4 class="title">
       <a name="resource-group-attributes">
       </a>
       Resource Group Attributes
      </h4>
     </div>
    </div>
   </div>
   <a class="indexterm" name="idm46045260255744">
   </a>
   <p>
    Resource groups have attributes that define the group. All
        attributes can be set at group creation time. Some attributes
        are fixed at creation time; others can be modified any time
        thereafter.
   </p>
   <p>
    These attributes are defined at resource group creation time and
        cannot be modified:
   </p>
   <div class="itemizedlist">
    <ul class="itemizedlist" style="list-style-type: disc; ">
     <li class="listitem">
      <p>
       Each group has a name. Resource group names are identifiers
            like table and column names, and need not be quoted in SQL
            statements unless they contain special characters or are
            reserved words. Group names are not case-sensitive and may
            be up to 64 characters long.
      </p>
     </li>
     <li class="listitem">
      <p>
       Each group has a type, which is either
       <code class="literal">
        SYSTEM
       </code>
       or
       <code class="literal">
        USER
       </code>
       . The
            resource group type affects the range of priority values
            assignable to the group, as described later. This attribute
            together with the differences in permitted priorities
            enables system threads to be identified so as to protect
            them from contention for CPU resources against user threads.
      </p>
      <p>
       System and user threads correspond to background and
            foreground threads as listed in the Performance Schema
       <a class="link" href="performance-schema-threads-table.html" title="29.12.22.8 The threads Table">
        <code class="literal">
         threads
        </code>
       </a>
       table.
      </p>
     </li>
    </ul>
   </div>
   <p>
    These attributes are defined at resource group creation time and
        can be modified any time thereafter:
   </p>
   <div class="itemizedlist">
    <ul class="itemizedlist" style="list-style-type: disc; ">
     <li class="listitem">
      <p>
       The CPU affinity is the set of virtual CPUs the resource
            group can use. An affinity can be any nonempty subset of the
            available CPUs. If a group has no affinity, it can use all
            available CPUs.
      </p>
     </li>
     <li class="listitem">
      <p>
       The thread priority is the execution priority for threads
            assigned to the resource group. Priority values range from
            -20 (highest priority) to 19 (lowest priority). The default
            priority is 0, for both system and user groups.
      </p>
      <p>
       System groups are permitted a higher priority than user
            groups, ensuring that user threads never have a higher
            priority than system threads:
      </p>
      <div class="itemizedlist">
       <ul class="itemizedlist" style="list-style-type: circle; ">
        <li class="listitem">
         <p>
          For system resource groups, the permitted priority range
                is -20 to 0.
         </p>
        </li>
        <li class="listitem">
         <p>
          For user resource groups, the permitted priority range
                is 0 to 19.
         </p>
        </li>
       </ul>
      </div>
     </li>
     <li class="listitem">
      <p>
       Each group can be enabled or disabled, affording
            administrators control over thread assignment. Threads can
            be assigned only to enabled groups.
      </p>
     </li>
    </ul>
   </div>
  </div>
  <div class="simplesect">
   <div class="titlepage">
    <div>
     <div class="simple">
      <h4 class="title">
       <a name="resource-group-management">
       </a>
       Resource Group Management
      </h4>
     </div>
    </div>
   </div>
   <a class="indexterm" name="idm46045260239104">
   </a>
   <p>
    By default, there is one system group and one user group, named
    <code class="literal">
     SYS_default
    </code>
    and
    <code class="literal">
     USR_default
    </code>
    , respectively. These default
        groups cannot be dropped and their attributes cannot be
        modified. Each default group has no CPU affinity and priority 0.
   </p>
   <p>
    Newly created system and user threads are assigned to the
    <code class="literal">
     SYS_default
    </code>
    and
    <code class="literal">
     USR_default
    </code>
    groups, respectively.
   </p>
   <p>
    For user-defined resource groups, all attributes are assigned at
        group creation time. After a group has been created, its
        attributes can be modified, with the exception of the name and
        type attributes.
   </p>
   <p>
    To create and manage user-defined resource groups, use these SQL
        statements:
   </p>
   <div class="itemizedlist">
    <ul class="itemizedlist" style="list-style-type: disc; ">
     <li class="listitem">
      <p>
       <a class="link" href="create-resource-group.html" title="15.7.2.2 CREATE RESOURCE GROUP Statement">
        <code class="literal">
         CREATE RESOURCE GROUP
        </code>
       </a>
       creates
            a new group. See
       <a class="xref" href="create-resource-group.html" title="15.7.2.2 CREATE RESOURCE GROUP Statement">
        Section 15.7.2.2, “CREATE RESOURCE GROUP Statement”
       </a>
       .
      </p>
     </li>
     <li class="listitem">
      <p>
       <a class="link" href="alter-resource-group.html" title="15.7.2.1 ALTER RESOURCE GROUP Statement">
        <code class="literal">
         ALTER RESOURCE GROUP
        </code>
       </a>
       modifies
            an existing group. See
       <a class="xref" href="alter-resource-group.html" title="15.7.2.1 ALTER RESOURCE GROUP Statement">
        Section 15.7.2.1, “ALTER RESOURCE GROUP Statement”
       </a>
       .
      </p>
     </li>
     <li class="listitem">
      <p>
       <a class="link" href="drop-resource-group.html" title="15.7.2.3 DROP RESOURCE GROUP Statement">
        <code class="literal">
         DROP RESOURCE GROUP
        </code>
       </a>
       drops an
            existing group. See
       <a class="xref" href="drop-resource-group.html" title="15.7.2.3 DROP RESOURCE GROUP Statement">
        Section 15.7.2.3, “DROP RESOURCE GROUP Statement”
       </a>
       .
      </p>
     </li>
    </ul>
   </div>
   <p>
    Those statements require the
    <a class="link" href="privileges-provided.html#priv_resource-group-admin">
     <code class="literal">
      RESOURCE_GROUP_ADMIN
     </code>
    </a>
    privilege.
   </p>
   <p>
    To manage resource group assignments, use these capabilities:
   </p>
   <div class="itemizedlist">
    <ul class="itemizedlist" style="list-style-type: disc; ">
     <li class="listitem">
      <p>
       <a class="link" href="set-resource-group.html" title="15.7.2.4 SET RESOURCE GROUP Statement">
        <code class="literal">
         SET RESOURCE GROUP
        </code>
       </a>
       assigns
            threads to a group. See
       <a class="xref" href="set-resource-group.html" title="15.7.2.4 SET RESOURCE GROUP Statement">
        Section 15.7.2.4, “SET RESOURCE GROUP Statement”
       </a>
       .
      </p>
     </li>
     <li class="listitem">
      <p>
       The
       <a class="link" href="optimizer-hints.html#optimizer-hints-resource-group" title="Resource Group Hint Syntax">
        <code class="literal">
         RESOURCE_GROUP
        </code>
       </a>
       optimizer hint assigns individual statements to a group. See
       <a class="xref" href="optimizer-hints.html" title="10.9.3 Optimizer Hints">
        Section 10.9.3, “Optimizer Hints”
       </a>
       .
      </p>
     </li>
    </ul>
   </div>
   <p>
    Those operations require the
    <a class="link" href="privileges-provided.html#priv_resource-group-admin">
     <code class="literal">
      RESOURCE_GROUP_ADMIN
     </code>
    </a>
    or
    <a class="link" href="privileges-provided.html#priv_resource-group-user">
     <code class="literal">
      RESOURCE_GROUP_USER
     </code>
    </a>
    privilege.
   </p>
   <p>
    Resource group definitions are stored in the
    <code class="literal">
     resource_groups
    </code>
    data dictionary table so that
        groups persist across server restarts. Because
    <code class="literal">
     resource_groups
    </code>
    is part of the data
        dictionary, it is not directly accessible by users. Resource
        group information is available using the Information Schema
    <a class="link" href="information-schema-resource-groups-table.html" title="28.3.26 The INFORMATION_SCHEMA RESOURCE_GROUPS Table">
     <code class="literal">
      RESOURCE_GROUPS
     </code>
    </a>
    table, which is
        implemented as a view on the data dictionary table. See
    <a class="xref" href="information-schema-resource-groups-table.html" title="28.3.26 The INFORMATION_SCHEMA RESOURCE_GROUPS Table">
     Section 28.3.26, “The INFORMATION_SCHEMA RESOURCE_GROUPS Table”
    </a>
    .
   </p>
   <p>
    Initially, the
    <a class="link" href="information-schema-resource-groups-table.html" title="28.3.26 The INFORMATION_SCHEMA RESOURCE_GROUPS Table">
     <code class="literal">
      RESOURCE_GROUPS
     </code>
    </a>
    table has these rows describing the default groups:
   </p>
   <div class="copytoclipboard-wrapper">
    <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa66622112"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> INFORMATION_SCHEMA<span class="token punctuation">.</span>RESOURCE_GROUPS\G
<span class="token output"><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span> 1. row <span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span>
   RESOURCE_GROUP_NAME<span class="token punctuation">:</span> USR_default
   RESOURCE_GROUP_TYPE<span class="token punctuation">:</span> USER
RESOURCE_GROUP_ENABLED<span class="token punctuation">:</span> 1
              VCPU_IDS<span class="token punctuation">:</span> 0-3
       THREAD_PRIORITY<span class="token punctuation">:</span> 0
<span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span> 2. row <span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span>
   RESOURCE_GROUP_NAME<span class="token punctuation">:</span> SYS_default
   RESOURCE_GROUP_TYPE<span class="token punctuation">:</span> SYSTEM
RESOURCE_GROUP_ENABLED<span class="token punctuation">:</span> 1
              VCPU_IDS<span class="token punctuation">:</span> 0-3
       THREAD_PRIORITY<span class="token punctuation">:</span> 0</span></code></pre>
   </div>
   <p>
    The
    <code class="literal">
     THREAD_PRIORITY
    </code>
    values are 0, indicating
        the default priority. The
    <code class="literal">
     VCPU_IDS
    </code>
    values
        show a range comprising all available CPUs. For the default
        groups, the displayed value varies depending on the system on
        which the MySQL server runs.
   </p>
   <p>
    Earlier discussion mentioned a scenario involving a resource
        group named
    <code class="literal">
     Batch
    </code>
    to manage execution of
        batch jobs that need not execute with high priority. To create
        such a group, use a statement similar to this:
   </p>
   <div class="copytoclipboard-wrapper">
    <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa8951867"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">CREATE</span> <span class="token keyword">RESOURCE</span> <span class="token keyword">GROUP</span> Batch
  <span class="token keyword">TYPE</span> <span class="token operator">=</span> <span class="token keyword">USER</span>
  <span class="token keyword">VCPU</span> <span class="token operator">=</span> <span class="token number">2</span><span class="token operator">-</span><span class="token number">3</span>            <span class="token comment" spellcheck="true">-- assumes a system with at least 4 CPUs</span>
  <span class="token keyword">THREAD_PRIORITY</span> <span class="token operator">=</span> <span class="token number">10</span><span class="token punctuation">;</span></code></pre>
   </div>
   <p>
    To verify that the resource group was created as expected, check
        the
    <a class="link" href="information-schema-resource-groups-table.html" title="28.3.26 The INFORMATION_SCHEMA RESOURCE_GROUPS Table">
     <code class="literal">
      RESOURCE_GROUPS
     </code>
    </a>
    table:
   </p>
   <div class="copytoclipboard-wrapper">
    <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa95868055"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> INFORMATION_SCHEMA<span class="token punctuation">.</span>RESOURCE_GROUPS
       <span class="token keyword">WHERE</span> RESOURCE_GROUP_NAME <span class="token operator">=</span> <span class="token string">'Batch'</span>\G
<span class="token output"><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span> 1. row <span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span>
   RESOURCE_GROUP_NAME<span class="token punctuation">:</span> Batch
   RESOURCE_GROUP_TYPE<span class="token punctuation">:</span> USER
RESOURCE_GROUP_ENABLED<span class="token punctuation">:</span> 1
              VCPU_IDS<span class="token punctuation">:</span> 2-3
       THREAD_PRIORITY<span class="token punctuation">:</span> 10</span></code></pre>
   </div>
   <p>
    If the
    <code class="literal">
     THREAD_PRIORITY
    </code>
    value is 0 rather than
        10, check whether your platform or system configuration limits
        the resource group capability; see
    <a class="xref" href="resource-groups.html#resource-group-restrictions" title="Resource Group Restrictions">
     Resource Group Restrictions
    </a>
    .
   </p>
   <p>
    To assign a thread to the
    <code class="literal">
     Batch
    </code>
    group, do
        this:
   </p>
   <div class="copytoclipboard-wrapper">
    <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa57787496"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SET</span> <span class="token keyword">RESOURCE</span> <span class="token keyword">GROUP</span> Batch <span class="token keyword">FOR</span> <em class="replaceable">thread_id</em><span class="token punctuation">;</span></code></pre>
   </div>
   <p>
    Thereafter, statements in the named thread execute with
    <code class="literal">
     Batch
    </code>
    group resources.
   </p>
   <p>
    If a session's own current thread should be in the
    <code class="literal">
     Batch
    </code>
    group, execute this statement within
        the session:
   </p>
   <div class="copytoclipboard-wrapper">
    <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa96337957"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SET</span> <span class="token keyword">RESOURCE</span> <span class="token keyword">GROUP</span> Batch<span class="token punctuation">;</span></code></pre>
   </div>
   <p>
    Thereafter, statements in the session execute with
    <code class="literal">
     Batch
    </code>
    group resources.
   </p>
   <p>
    To execute a single statement using the
    <code class="literal">
     Batch
    </code>
    group, use the
    <a class="link" href="optimizer-hints.html#optimizer-hints-resource-group" title="Resource Group Hint Syntax">
     <code class="literal">
      RESOURCE_GROUP
     </code>
    </a>
    optimizer hint:
   </p>
   <div class="copytoclipboard-wrapper">
    <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa2152698"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">INSERT</span> <span class="token comment" spellcheck="true">/*+ RESOURCE_GROUP(Batch) */</span> <span class="token keyword">INTO</span> t2 <span class="token keyword">VALUES</span><span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
   </div>
   <p>
    Threads assigned to the
    <code class="literal">
     Batch
    </code>
    group execute
        with its resources, which can be modified as desired:
   </p>
   <div class="itemizedlist">
    <ul class="itemizedlist" style="list-style-type: disc; ">
     <li class="listitem">
      <p>
       For times when the system is highly loaded, decrease the
            number of CPUs assigned to the group, lower its priority, or
            (as shown) both:
      </p>
      <div class="copytoclipboard-wrapper">
       <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa55282027"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">ALTER</span> <span class="token keyword">RESOURCE</span> <span class="token keyword">GROUP</span> Batch
  <span class="token keyword">VCPU</span> <span class="token operator">=</span> <span class="token number">3</span>
  <span class="token keyword">THREAD_PRIORITY</span> <span class="token operator">=</span> <span class="token number">19</span><span class="token punctuation">;</span></code></pre>
      </div>
     </li>
     <li class="listitem">
      <p>
       For times when the system is lightly loaded, increase the
            number of CPUs assigned to the group, raise its priority, or
            (as shown) both:
      </p>
      <div class="copytoclipboard-wrapper">
       <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa52537407"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">ALTER</span> <span class="token keyword">RESOURCE</span> <span class="token keyword">GROUP</span> Batch
  <span class="token keyword">VCPU</span> <span class="token operator">=</span> <span class="token number">0</span><span class="token operator">-</span><span class="token number">3</span>
  <span class="token keyword">THREAD_PRIORITY</span> <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span></code></pre>
      </div>
     </li>
    </ul>
   </div>
  </div>
  <div class="simplesect">
   <div class="titlepage">
    <div>
     <div class="simple">
      <h4 class="title">
       <a name="resource-group-replication">
       </a>
       Resource Group Replication
      </h4>
     </div>
    </div>
   </div>
   <a class="indexterm" name="idm46045260175536">
   </a>
   <p>
    Resource group management is local to the server on which it
        occurs. Resource group SQL statements and modifications to the
    <code class="literal">
     resource_groups
    </code>
    data dictionary table are not
        written to the binary log and are not replicated.
   </p>
  </div>
  <div class="simplesect">
   <div class="titlepage">
    <div>
     <div class="simple">
      <h4 class="title">
       <a name="resource-group-restrictions">
       </a>
       Resource Group Restrictions
      </h4>
     </div>
    </div>
   </div>
   <a class="indexterm" name="idm46045260171488">
   </a>
   <a class="indexterm" name="idm46045260170000">
   </a>
   <p>
    On some platforms or MySQL server configurations, resource
        groups are unavailable or have limitations:
   </p>
   <div class="itemizedlist">
    <ul class="itemizedlist" style="list-style-type: disc; ">
     <li class="listitem">
      <p>
       Resource groups are unavailable if the thread pool plugin is
            installed.
      </p>
      <a class="indexterm" name="idm46045260166960">
      </a>
     </li>
     <li class="listitem">
      <p>
       Resource groups are unavailable on macOS, which provides no
            API for binding CPUs to a thread.
      </p>
     </li>
     <li class="listitem">
      <p>
       On FreeBSD and Solaris, resource group thread priorities are
            ignored. (Effectively, all threads run at priority 0.)
            Attempts to change priorities result in a warning:
      </p>
      <div class="copytoclipboard-wrapper">
       <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa75967417"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">ALTER</span> <span class="token keyword">RESOURCE</span> <span class="token keyword">GROUP</span> abc <span class="token keyword">THREAD_PRIORITY</span> <span class="token operator">=</span> <span class="token number">10</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected, 1 warning (0.18 sec)</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">SHOW</span> <span class="token keyword">WARNINGS</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> Level   <span class="token punctuation">|</span> Code <span class="token punctuation">|</span> Message                                                     <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> Warning <span class="token punctuation">|</span> 4560 <span class="token punctuation">|</span> Attribute thread_priority is ignored (using default value). <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
      </div>
     </li>
     <li class="listitem">
      <p>
       On Linux, resource groups thread priorities are ignored
            unless the
       <code class="literal">
        CAP_SYS_NICE
       </code>
       capability is
            set. Granting
       <code class="literal">
        CAP_SYS_NICE
       </code>
       capability to
            a process enables a range of privileges; consult
       <a class="ulink" href="http://man7.org/linux/man-pages/man7/capabilities.7.html" target="_blank">
        http://man7.org/linux/man-pages/man7/capabilities.7.html
       </a>
       for the full list. Please be careful when enabling this
            capability.
      </p>
      <p>
       On Linux platforms using systemd and kernel support for
            Ambient Capabilities (Linux 4.3 or newer), the recommended
            way to enable
       <code class="literal">
        CAP_SYS_NICE
       </code>
       capability is
            to modify the MySQL service file and leave the
       <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
        <span class="command">
         <strong>
          mysqld
         </strong>
        </span>
       </a>
       binary unmodified. To adjust the
            service file for MySQL, use this procedure:
      </p>
      <div class="orderedlist">
       <ol class="orderedlist" type="1">
        <li class="listitem">
         <p>
          Run the appropriate command for your platform:
         </p>
         <div class="itemizedlist">
          <ul class="itemizedlist" style="list-style-type: circle; ">
           <li class="listitem">
            <p>
             Oracle Linux, Red Hat, and Fedora systems:
            </p>
            <div class="copytoclipboard-wrapper">
             <pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa46074179"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$&gt; </span><span class="token command">sudo</span> systemctl edit mysqld</code></pre>
            </div>
           </li>
           <li class="listitem">
            <p>
             SUSE, Ubuntu, and Debian systems:
            </p>
            <div class="copytoclipboard-wrapper">
             <pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa96976010"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$&gt; </span><span class="token command">sudo</span> systemctl edit mysql</code></pre>
            </div>
           </li>
          </ul>
         </div>
        </li>
        <li class="listitem">
         <p>
          Using an editor, add the following text to the service
                file:
         </p>
         <div class="copytoclipboard-wrapper">
          <pre class="programlisting language-ini"><div class="docs-select-all right" id="sa27244530"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-ini"><span class="token selector">[Service]</span>
<span class="token constant">AmbientCapabilities</span><span class="token attr-value"><span class="token punctuation">=</span>CAP_SYS_NICE</span></code></pre>
         </div>
        </li>
        <li class="listitem">
         <p>
          Restart the MySQL service.
         </p>
        </li>
       </ol>
      </div>
      <p>
       If you cannot enable the
       <code class="literal">
        CAP_SYS_NICE
       </code>
       capability as just described, it can be set manually using
            the
       <span class="command">
        <strong>
         setcap
        </strong>
       </span>
       command, specifying the path
            name to the
       <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
        <span class="command">
         <strong>
          mysqld
         </strong>
        </span>
       </a>
       executable (this
            requires
       <span class="command">
        <strong>
         sudo
        </strong>
       </span>
       access). You can check the
            capabilities using
       <span class="command">
        <strong>
         getcap
        </strong>
       </span>
       . For example:
      </p>
      <div class="copytoclipboard-wrapper">
       <pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa37122869"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$&gt; </span><span class="token command">sudo</span> setcap cap_sys_nice+ep <em class="replaceable">/path/to/mysqld</em>
<span class="token prompt">$&gt; </span><span class="token command">getcap</span> <em class="replaceable">/path/to/mysqld</em>
<em class="replaceable">/path/to/mysqld</em> = cap_sys_nice+ep</code></pre>
      </div>
      <p>
       As a safety measure, restrict execution of the
       <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
        <span class="command">
         <strong>
          mysqld
         </strong>
        </span>
       </a>
       binary to the
       <code class="literal">
        root
       </code>
       user and users with
       <code class="literal">
        mysql
       </code>
       group membership:
      </p>
      <div class="copytoclipboard-wrapper">
       <pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa9854294"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$&gt; </span><span class="token command">sudo</span> chown root<span class="token punctuation">:</span>mysql <em class="replaceable">/path/to/mysqld</em>
<span class="token prompt">$&gt; </span><span class="token command">sudo</span> chmod 0750 <em class="replaceable">/path/to/mysqld</em></code></pre>
      </div>
      <div class="important" style="margin-left: 0.5in; margin-right: 0.5in;">
       <div class="admon-title">
        Important
       </div>
       <p>
        If manual use of
        <span class="command">
         <strong>
          setcap
         </strong>
        </span>
        is required, it
              must be performed after each reinstall.
       </p>
      </div>
     </li>
     <li class="listitem">
      <p>
       On Windows, threads run at one of five thread priority
            levels. The resource group thread priority range of -20 to
            19 maps onto those levels as indicated in the following
            table.
      </p>
      <div class="table">
       <a name="windows-thread-priority-table">
       </a>
       <p class="title">
        <b>
         Table 7.6 Resource Group Thread Priority on Windows
        </b>
       </p>
       <div class="table-contents">
        <table summary="Priority ranges for resource group threads on Windows.">
         <colgroup>
          <col style="width: 20%"/>
          <col style="width: 40%"/>
         </colgroup>
         <thead>
          <tr>
           <th>
            Priority Range
           </th>
           <th>
            Windows Priority Level
           </th>
          </tr>
         </thead>
         <tbody>
          <tr>
           <td>
            -20 to -10
           </td>
           <td>
            <code class="literal">
             THREAD_PRIORITY_HIGHEST
            </code>
           </td>
          </tr>
          <tr>
           <td>
            -9 to -1
           </td>
           <td>
            <code class="literal">
             THREAD_PRIORITY_ABOVE_NORMAL
            </code>
           </td>
          </tr>
          <tr>
           <td>
            0
           </td>
           <td>
            <code class="literal">
             THREAD_PRIORITY_NORMAL
            </code>
           </td>
          </tr>
          <tr>
           <td>
            1 to 10
           </td>
           <td>
            <code class="literal">
             THREAD_PRIORITY_BELOW_NORMAL
            </code>
           </td>
          </tr>
          <tr>
           <td>
            11 to 19
           </td>
           <td>
            <code class="literal">
             THREAD_PRIORITY_LOWEST
            </code>
           </td>
          </tr>
         </tbody>
        </table>
       </div>
      </div>
      <br class="table-break"/>
     </li>
    </ul>
   </div>
  </div>
 </div>
 <br/>
</div>
