
{"id":7176,"date":"2021-12-01T17:38:36","date_gmt":"2021-12-01T17:38:36","guid":{"rendered":"https:\/\/rax-stg-wp-aws.com\/blogs\/sql-quarantine\/"},"modified":"2026-11-03T19:28:10","modified_gmt":"2026-11-03T19:28:10","slug":"sql-quarantine","status":"publish","type":"blogs","link":"https:\/\/www.rackspace.com\/de\/blogs\/sql-quarantine\/","title":{"rendered":"SQL quarantine"},"content":{"rendered":"<p>This blog post introduces the concept of SQL Quarantine. By using Oracle\u00ae Resource Manager, you can regulate and limit the use of resources like CPU and I\/O, among others. The most interesting fact is that you can prevent the execution of any long-running queries that exceed a defined threshold.<\/p>\n<p><strong>What is SQL quarantine?<\/strong><\/p>\n<p>Quarantine means isolation. SQL quarantine is a version 19c feature that you can use to eliminate the overhead of runaway queries. Runaway queries end up being terminated by the Resource Manager because they exceed a resource or a runtime limit and use lots of resources, CPU, and IO.<\/p>\n<p>This feature is available for only Exadata (Oracle Database Enterprise Edition on Engineered Systems) and DBCS\/ExaCS (Oracle Database Exadata Cloud Service). To test this out, I set the underscore parameter and bounced the database by using the following command:<\/p>\n<p class=\"text-align-center\">&nbsp;Alter system set&#8221;_exadata_feature_on&#8221;=true scope=spfile;<\/p>\n<p><strong>What about long-running queries?<\/strong><\/p>\n<p>The Database Resource Manager (DBRM) is a background process that lets you terminate an SQL statement that exceeds certain resource utilization thresholds such as IO and CPU. It also can terminate any queries that exceed maximum run-time thresholds.<\/p>\n<p>Any marked SQL execution plan and the SQL statement that exceed the limit is quarantined, which implies that if the same SQL runs again, using the same execution plan, the SQL statement will be terminated and flash the following error:<\/p>\n<p class=\"text-align-center\">&nbsp; error: ORA-56955: quarantined plan used.&nbsp;<\/p>\n<p>\nWhen these errors occur, Object Quarantine isolates the object that caused the error and then monitors it to see its impact on the rest of the Database.<\/p>\n<p>I&#8217;m not referring to the tables and indexes but to the objects that Oracle can quarantine, including sessions, processes, SGA transactions, and a library cache.<\/p>\n<p>You can now terminate or cancel any SQL query that runs longer than a given threshold of time, such as the following example:<\/p>\n<p><img decoding=\"async\" src=\"\/wp-content\/uploads\/2026\/blog_article_images\/26292-body-Picture1_35.png\" alt=\"quarantine pic 1\" \/><\/p>\n<p><strong>Figure 1: Runaway SQL Statement&nbsp;<\/strong><\/p>\n<p><a href=\"https:\/\/www.oracle.com\/technetwork\/database\/bi-datawarehousing\/twp-optimizer-with-oracledb-19c-5324206.pdf\">Refer Source PDF&#8217;s URL<\/a><\/p>\n<p><strong>Find out about quarantined objects<\/strong><\/p>\n<p><strong>According to <a href=\"http:\/\/dbaparadise.com\/2020\/01\/everything-you-need-to-know-about-quarantined-objects\">DBA Paradise<\/a>:&nbsp;<\/strong>To get the information about quarantined objects, you can query <strong>V$QUARANTINE<\/strong>&nbsp;and&nbsp;<strong>V$QUARANTINE_SUMMARY<\/strong> views, which tell you the object&#8217;s type, the object&#8217;s memory address, the actual ORA- error, and the error&#8217;s date and time.&nbsp;<\/p>\n<p>As shown in the following example, you can assume that the CPU utilization in the server looks like the runaway queries&#8217; response when executed. We can see three queries running concurrently, utilizing the CPU to nearly 100% of its capacity.<\/p>\n<p><img decoding=\"async\" src=\"\/wp-content\/uploads\/2026\/blog_article_images\/26292-body-Picture2_26.png\" alt=\"quarantine pic 2\" \/><\/p>\n<p class=\"text-align-center\"><strong>Figure 2: CPU consumed by Runaway SQL<\/strong>&nbsp;<\/p>\n<p class=\"text-align-center\"><a href=\"https:\/\/www.oracle.com\/technetwork\/database\/bi-datawarehousing\/twp-optimizer-with-oracledb-19c-5324206.pdf\">Image source&nbsp;reference pdf<\/a><\/p>\n<p><strong>SQL Quarantine<\/strong><\/p>\n<p>You can use SQL Quarantine to eliminate the overhead of runaway queries. When the Resource Manager detects an SQL statement exceeding a resource or run-time limit, the SQL execution plan used by the statement gets quarantined.<\/p>\n<p>If the same SQL statement executes by using the same SQL plan, it gets terminated immediately. This helps to reduce system resource usage significantly. In the following figure, you can see high utilization when a few queries execute. However, by terminating them before execution, they no longer consume system resources after being quarantined.<\/p>\n<p><img decoding=\"async\" src=\"\/wp-content\/uploads\/2026\/blog_article_images\/26292-body-Picture3_28.png\" alt=\"quarantine pic 3\" \/><\/p>\n<p class=\"text-align-center\"><strong>Figure &nbsp;3: CPU saved by SQL quarantine<\/strong><\/p>\n<p class=\"text-align-center\"><a href=\"https:\/\/www.oracle.com\/technetwork\/database\/bi-datawarehousing\/twp-optimizer-with-oracledb-19c-5324206.pdf\">Image Source PDF<\/a><\/p>\n<p><strong>Steps to use the quarantine feature<\/strong><\/p>\n<p>Let&#8217;s check the feature and how it works.<\/p>\n<p>First, you have to set up the database as you are working on Exadata.<\/p>\n<p><em>alter system set &#8220;_exadata_feature_on&#8221;=true scope=spfile;<br \/>\n&nbsp; &nbsp; &nbsp; shutdown immediate;<br \/>\n&nbsp; &nbsp; &nbsp; startup;<\/em><\/p>\n<p>Then, you need to complete the following steps to setup Resource Manager:<\/p>\n<p>1. Creating a pending area:<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; begin<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; dbms_resource_manager.create_pending_area();<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; end;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; \/<\/p>\n<p>2. Create one or more resource consumer groups:<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; begin<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; dbms_resource_manager.create_consumer_group(CONSUMER_GROUP=&gt;&#8217;. &nbsp; SQL_LIMIT&#8217;,COMMENT=&gt;&#8217;consumer group&#8217;);<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; end;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; \/<\/p>\n<p>3. Create resource plans:<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; begin<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; dbms_resource_manager.set_consumer_group_mapping(attribute =&gt; <em>ORACLE_USER<\/em>,value =&gt; <em>DBA1<\/em>,consumer_group =&gt;<em>SQL_LIMIT<\/em>&nbsp;);<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; dbms_resource_manager.create_plan(PLAN=&gt; <em>NEW_PLAN<\/em>,COMMENT=&gt;<em>Kill statement after exceeding total execution time<\/em>&#8216;);<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; end;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\/<\/p>\n<p>4. Create resource plan directives. The CANCEL_SQL group already exists by default:<\/p>\n<p><em>&nbsp; &nbsp; &nbsp; &nbsp; begin<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; dbms_resource_manager.create_plan_directive(<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; plan =&gt; &#8216;NEW_PLAN&#8217;,<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; group_or_subplan =&gt; &#8216;SQL_LIMIT&#8217;,<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; comment =&gt; &#8216;Kill statement after exceeding total execution time&#8217;,<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; switch_group=&gt;&#8217;CANCEL_SQL&#8217;,<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; switch_time =&gt; 10,<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; switch_estimate=&gt;false);<\/em><br \/>\n&nbsp;<em> &nbsp; &nbsp; &nbsp; end;<\/em><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; \/<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; begin<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; dbms_resource_manager.create_plan_directive(PLAN=&gt; <em>NEW_PLAN<\/em>, &nbsp; &nbsp; &nbsp; &nbsp;GROUP_OR_SUBPLAN=&gt;<em>OTHER_GROUPS<\/em>,COMMENT=&gt;<em>leave others alone<\/em>, CPU_P1=&gt;100 );<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; end;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; \/<\/p>\n<p>5. Validate and submit the pending area for plan, consumer group, and directives:<br \/>\n&nbsp;<br \/>\n<em>&nbsp; &nbsp; &nbsp; &nbsp; begin<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; dbms_resource_manager.validate_pending_area();<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; end;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; \/<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; begin<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; dbms_resource_manager.submit_pending_area();<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; end;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; \/<\/em><\/p>\n<p>Here you need to assign the grants and assign consumer groups to the users.<\/p>\n<p>6. Create a pending area for privileges, roles, and assigned users:<\/p>\n<p><em>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;dbms_resource_manager.create_pending_area();<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\/<\/em><\/p>\n<p>7. Grant switch privilege for resource consumer groups to users or roles.<\/p>\n<p><em>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dbms_resource_manager_privs.grant_switch_consumer_group(&#8216;DBA1&#8242;,&#8217;SQL_LIMIT&#8217;,false);<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \/<\/em><\/p>\n<p>8. Assign users to resource consumer groups.<\/p>\n<p><em>&nbsp; &nbsp; &nbsp; &nbsp; begin<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; dbms_resource_manager.set_initial_consumer_group(&#8216;DBA1&#8242;,&#8217;SQL_LIMIT&#8217;);<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; end;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; \/<\/em><\/p>\n<p>9. Validate and submit the pending areas.<\/p>\n<p>&nbsp; &nbsp;<em> &nbsp; &nbsp; begin<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; dbms_resource_manager.validate_pending_area();<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; end;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; \/<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; begin<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; dbms_resource_manager.submit_pending_area();<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; end;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; \/<\/em><\/p>\n<p>10. Now, you have to update the Plan and again need to submit the pending area.<\/p>\n<p>&nbsp; &nbsp; &nbsp;<em> &nbsp; begin<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; dbms_resource_manager.clear_pending_area;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; dbms_resource_manager_create_pending_area;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; end;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; \/<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; begin<\/em><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; dbms_resource_manager.update_plan_directive(plan=&gt;<em>NEW_PLAN<\/em>,group_or_subplan=&gt;<em>SQL_LIMIT<\/em>,new_switch_elapsed_time=&gt;10, <em>new_switch_for_call=&gt;TRUE,new_switch_group=&gt;CANCEL_SQL);<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; end;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; \/<\/em><\/p>\n<p><em>&nbsp; &nbsp; &nbsp; &nbsp; begin &nbsp;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; dbms_resource_manager.validate_pending_area();<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; dbms_resource_manager.submit_pending_area;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; end;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; \/<\/em><\/p>\n<p><strong>Next steps<\/strong><\/p>\n<p>The preceding steps complete the Resource Manager Setup. After the complete them, all you need to do is to assign this Plan to an instance:<\/p>\n<p class=\"text-align-center\">&nbsp; &nbsp; ALTER SYSTEM SET RESOURCE_MANAGER_PLAN=NEW_PLAN;<\/p>\n<p>Log in with the DBA1 user and issue a query that will exceed the elapsed time threshold of 10 seconds defined in the resource plan.<\/p>\n<p>You must execute the statement as the DBA1 user, and DBA1 must have access to the DBA views.<\/p>\n<p><em>&nbsp; &nbsp; select a.owner_name,b.product_name,c.location,d.country_code<br \/>\n&nbsp; &nbsp; from import_pr_table a, item_table b, locate_dealer_table c,country_table d;<\/em><\/p>\n<p>&nbsp; &nbsp; ERROR at line 1:<br \/>\n&nbsp; &nbsp; ORA-00040: active time limit exceeded &#8211; call aborted<\/p>\n<p>Notice that in this case, the Resource Manager terminated the execution with an `ORA-00040` error.<\/p>\n<p>Can you find the SQL_ID of the statement? It is `<em>3hdkutq4krg4c<\/em>`.<\/p>\n<p><strong>Create SQL Quarantine<\/strong><\/p>\n<p>You can use the <strong>DBMS_SQLQ<\/strong>&nbsp;package to create a quarantine configuration for an execution plan of an SQL statement that needs to be quarantined.&nbsp;<\/p>\n<p>You can use SQL text or the SQL_ID of the statement to be quarantined, as shown in the following example:<\/p>\n<p><em>&nbsp; &nbsp; CREATE_QUARANTINE_BY_SQL_ID &nbsp;<br \/>\n&nbsp; &nbsp; or&nbsp;<br \/>\n&nbsp; &nbsp; CREATE_QUARANTINE_BY_SQL_TEXT<\/em><\/p>\n<p><em>&nbsp; &nbsp; DECLARE<br \/>\n&nbsp; &nbsp; quarantine_sql VARCHAR2(30);<br \/>\n&nbsp; &nbsp; BEGIN<br \/>\n&nbsp; &nbsp; quarantine_sql := &nbsp; DBMS_SQLQ.CREATE_QUARANTINE_BY_SQL_ID(SQL_ID =&gt; &#8216;3hdkutq4krg4c&#8217;);<br \/>\n&nbsp; &nbsp; END;<br \/>\n&nbsp; &nbsp; \/<\/em><br \/>\n&nbsp;<\/p>\n<p>After you create this quarantine configuration, you can specify quarantine thresholds by using the <strong>DBMS_SQLQ.ALTER_QUARANTINE<\/strong> procedure.&nbsp;<\/p>\n<p>\nWith SQL Quarantine in place, it does not execute if you try to run the same SQL statement<\/p>\n<p>\n<em>&nbsp; &nbsp; select a.owner_name,b.product_name,c.location,d.country_code from &nbsp; &nbsp; import_pr_table a, item_table b, locate_dealer_table c,country_table d;<br \/>\n&nbsp; &nbsp; ERROR at line 1:<br \/>\n&nbsp; &nbsp; ORA-56955: quarantined plan used<\/em><\/p>\n<p>The preceding error message states that the plan used for this statement is part of a quarantined plan. It canceled the query because it has crossed the threshold limit<em>.<\/em><\/p>\n<p>If you check <strong>V$SQL<\/strong>&nbsp;view, you see two new columns: <strong>sql_quarantine<\/strong>&nbsp;and&nbsp;<strong>avoided_executions<\/strong>:<\/p>\n<p><em>&nbsp; &nbsp; select sql_quarantine,avoided_executions from v$sql where &nbsp; &nbsp;sql_id=&#8217;3hdkutq4krg4c&#8217;;<br \/>\n&nbsp; &nbsp; SQL&gt; select sql_quarantine,avoided_executions<br \/>\n&nbsp; &nbsp; &nbsp; 2 &nbsp;from v$sql where sql_id=&#8217;3hdkutq4krg4c&#8217;;<\/em><\/p>\n<p><em>&nbsp; &nbsp; SQL_QUARANTINE &nbsp; &nbsp; &nbsp; AVOIDED_EXECUTIONS<br \/>\n&nbsp; &nbsp; &#8212;&#8212;&#8212;&#8212;&#8212; &nbsp; &nbsp; &nbsp;&#8212;&#8212;&#8212;&#8212;&#8212;<br \/>\n&nbsp; &nbsp; &nbsp;SQL_QUARANTINE_3hdkutq4krg4c &nbsp;&nbsp;<br \/>\n&nbsp; &nbsp; 1&nbsp;<\/em><\/p>\n<p><strong>Conclusion<\/strong><\/p>\n<p>The SQL Quarantine feature helps improve the performance because it prevents the future execution of a costly, quarantined SQL statement.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>SQL quarantine<\/p>\n","protected":false},"author":2,"featured_media":7178,"menu_order":0,"comment_status":"open","ping_status":"open","template":"","format":"standard","meta":{"content-type":"","nid":"26292","content_type":"blog","created_by":"10130","authored_on":"2023-11-25T17:38:36+00:00","field_article_industries":"","tag_category":"Technical","field_blog_author_text":"by Ravikant Sharma, Oracle Database Administrator, Rackspace Technology","seo_description":"Manage and limit resource use with SQL Quarantine in Oracle Resource Manager. Prevent overreaching of defined thresholds.\r\n","field_featured_image":"","insights_image":"\/wp-content\/uploads\/2026\/blog_technical_images\/26292-insights_image-oracle-technical-blog-1-insights.jpg","field_partners":"","rxt_platforms":"Oracle","product":"","publisheddate":"2021-12-01T17:38:36","rxt_solutions":"Databases","opengraph_tag":"","x_tag":"","teaser_flag":"Technical Blog","seo_titile":"SQL Quarantine Query Isolation | Rackspace Technology","field_topics":"","field_slug":"sql-quarantine","footnotes":""},"categories":[178],"tags":[204],"class_list":["post-7176","blogs","type-blogs","status-publish","format-standard","has-post-thumbnail","hentry","category-blog","tag-technical"],"_links":{"self":[{"href":"https:\/\/www.rackspace.com\/de\/wp-json\/wp\/v2\/blogs\/7176","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rackspace.com\/de\/wp-json\/wp\/v2\/blogs"}],"about":[{"href":"https:\/\/www.rackspace.com\/de\/wp-json\/wp\/v2\/types\/blogs"}],"author":[{"embeddable":true,"href":"https:\/\/www.rackspace.com\/de\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rackspace.com\/de\/wp-json\/wp\/v2\/comments?post=7176"}],"version-history":[{"count":2,"href":"https:\/\/www.rackspace.com\/de\/wp-json\/wp\/v2\/blogs\/7176\/revisions"}],"predecessor-version":[{"id":9106,"href":"https:\/\/www.rackspace.com\/de\/wp-json\/wp\/v2\/blogs\/7176\/revisions\/9106"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.rackspace.com\/de\/wp-json\/wp\/v2\/media\/7178"}],"wp:attachment":[{"href":"https:\/\/www.rackspace.com\/de\/wp-json\/wp\/v2\/media?parent=7176"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rackspace.com\/de\/wp-json\/wp\/v2\/categories?post=7176"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rackspace.com\/de\/wp-json\/wp\/v2\/tags?post=7176"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}