<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h4 class="title">
      <a name="set-resource-group">
      </a>
      15.7.2.4 SET RESOURCE GROUP Statement
     </h4>
    </div>
   </div>
  </div>
  <a class="indexterm" name="idm46045172741456">
  </a>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa45607152"><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> <em class="replaceable">group_name</em>
    <span class="token punctuation">[</span><span class="token keyword">FOR</span> <em class="replaceable">thread_id</em> <span class="token punctuation">[</span><span class="token punctuation">,</span> <em class="replaceable">thread_id</em><span class="token punctuation">]</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">]</span></code></pre>
  </div>
  <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>
   is used for
        resource group management (see
   <a class="xref" href="resource-groups.html" title="7.1.16 Resource Groups">
    Section 7.1.16, “Resource Groups”
   </a>
   ). This statement assigns
        threads to a resource group. It requires 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>
   <em class="replaceable">
    <code>
     group_name
    </code>
   </em>
   identifies which resource
        group to be assigned. Any
   <em class="replaceable">
    <code>
     thread_id
    </code>
   </em>
   values indicate threads to assign to the group. Thread IDs can
        be determined from 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. If the resource
        group or any named thread ID does not exist, an error occurs.
  </p>
  <p>
   With no
   <code class="literal">
    FOR
   </code>
   clause, the statement assigns the
        current thread for the session to the resource group.
  </p>
  <p>
   With a
   <code class="literal">
    FOR
   </code>
   clause that names thread IDs, the
        statement assigns those threads to the resource group.
  </p>
  <p>
   For attempts to assign a system thread to a user resource group
        or a user thread to a system resource group, a warning occurs.
  </p>
  <p>
   Examples:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      Assign the current session thread to a group:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa18639267"><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> rg1<span class="token punctuation">;</span></code></pre>
     </div>
    </li>
    <li class="listitem">
     <p>
      Assign the named threads to a group:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa97818991"><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> rg2 <span class="token keyword">FOR</span> <span class="token number">14</span><span class="token punctuation">,</span> <span class="token number">78</span><span class="token punctuation">,</span> <span class="token number">4</span><span class="token punctuation">;</span></code></pre>
     </div>
    </li>
   </ul>
  </div>
  <p>
   Resource group management is local to the server on which it
        occurs.
   <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>
   statements are not written to the binary log and are not
        replicated.
  </p>
  <p>
   An alternative to
   <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>
   is 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,
        which assigns individual statements to a resource group. See
   <a class="xref" href="optimizer-hints.html" title="10.9.3 Optimizer Hints">
    Section 10.9.3, “Optimizer Hints”
   </a>
   .
  </p>
 </div>
 <br/>
</div>
