{"id":8402,"date":"2016-06-20T18:15:59","date_gmt":"2016-06-20T16:15:59","guid":{"rendered":"https:\/\/www.dbi-services.com\/blog\/when-changing-cursor_sharing-takes-effect\/"},"modified":"2016-06-20T18:15:59","modified_gmt":"2016-06-20T16:15:59","slug":"when-changing-cursor_sharing-takes-effect","status":"publish","type":"post","link":"https:\/\/www.dbi-services.com\/blog\/when-changing-cursor_sharing-takes-effect\/","title":{"rendered":"When changing CURSOR_SHARING takes effect?"},"content":{"rendered":"<h2>By Franck Pachot<\/h2>\n<p>.<br \/>\nI usually don&#8217;t advice to set CURSOR_SHARING=FORCE but imagine your application requires it, you forgot it (or tried to do without) on migration and then everything is slow. You want to change it, but when does it take effect? New execution? New parsing? New session?<\/p>\n<h3>EXACT<\/h3>\n<p>I have the default value where parent cursor is shared only when sql_text is the same:<\/p>\n<pre><code>\nSQL&gt; show parameter cursor_sharing\n&nbsp;\nNAME                                 TYPE        VALUE\n------------------------------------ ----------- ------------------------------\ncursor_sharing                       string      EXACT\n<\/code><\/pre>\n<p>And I check with a query that the predicate is not changed:<\/p>\n<pre><code>\nSQL&gt; select * from dual where dummy='X';\n&nbsp;\nD\n-\nX\n&nbsp;\nSQL&gt; select * from table(dbms_xplan.display_cursor) where plan_table_output like '%filter%';\n&nbsp;\nPLAN_TABLE_OUTPUT\n--------------------------------------------------------------------------------\n   1 - filter(\"DUMMY\"='X')\n<\/code><\/pre>\n<h3>FORCE<\/h3>\n<p>I change at system (=instance) level<\/p>\n<pre><code>\nSQL&gt; alter system set cursor_sharing=force;\nSystem altered.\n&nbsp;\nSQL&gt; show parameter cursor_sharing\n&nbsp;\nNAME                                 TYPE        VALUE\n------------------------------------ ----------- ------------------------------\ncursor_sharing                       string      FORCE\n<\/code><\/pre>\n<p>I tested without session cached cursors:<\/p>\n<pre><code>\nSQL&gt; alter session set session_cached_cursors=0;\nSession altered.\n<\/code><\/pre>\n<p>and even from another session<\/p>\n<pre><code>\nSQL&gt; connect \/ as sysdba\nConnected.\n<\/code><\/pre>\n<p>But the predicate still has its predicate:<\/p>\n<pre><code>\nSQL&gt; select * from dual where dummy='X';\n&nbsp;\nD\n-\nX\n&nbsp;\nSQL&gt; select * from table(dbms_xplan.display_cursor) where plan_table_output like '%filter%';\n&nbsp;\nPLAN_TABLE_OUTPUT\n--------------------------------------------------------------------------------\n   1 - filter(\"DUMMY\"='X')\n<\/code><\/pre>\n<p>No invalidation, no new cursor. Same old statement.<\/p>\n<h3>FLUSH SHARED_POOL<\/h3>\n<p>Only when I flush the shared_pool I can execute the statement with literals replaced:<\/p>\n<pre><code>\nSQL&gt; alter system flush shared_pool;\nSystem altered.\n&nbsp;\nSQL&gt; select * from dual where dummy='X';\n&nbsp;\nD\n-\nX\n&nbsp;\nSQL&gt; select * from table(dbms_xplan.display_cursor) where plan_table_output like '%filter%';\n&nbsp;\nPLAN_TABLE_OUTPUT\n--------------------------------------------------------------------------------\n   1 - filter(\"DUMMY\"=:SYS_B_0)\n<\/code><\/pre>\n<p><del datetime=\"2016-06-27T08:51:33+00:00\">If you fear a hard parse fest, you can flush specific cursors. I&#8217;ve documented the procedure in a <a href=\"http:\/\/dbi-services.com\/blog\/flush-one-sql-statement-to-hard-parse-it-again\/\" target=\"_blank\" rel=\"noopener noreferrer\">previous post<\/a>.<\/del><\/p>\n<h3>Update 27-JUN-2016<\/h3>\n<p>The previous sentence was wrong. Unfortunately, dbms_shared_pool.purge purges only the library cache object heaps and not the object handles. So this is not a solution to get cursor_sharing change immediate effect.<\/p>\n<h3>Autotrace<\/h3>\n<p>As a side note, do not rely on autotrace for that<\/p>\n<pre><code>\nSQL&gt; set autotrace on explain\nSQL&gt; select * from dual where dummy='X';\n&nbsp;\nD\n-\nX\n&nbsp;\nExecution Plan\n----------------------------------------------------------\nPlan hash value: 272002086\n&nbsp;\n--------------------------------------------------------------------------\n| Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |\n--------------------------------------------------------------------------\n|   0 | SELECT STATEMENT  |      |     1 |     2 |     2   (0)| 00:00:01 |\n|*  1 |  TABLE ACCESS FULL| DUAL |     1 |     2 |     2   (0)| 00:00:01 |\n--------------------------------------------------------------------------\n&nbsp;\nPredicate Information (identified by operation id):\n---------------------------------------------------\n&nbsp;\n   1 - filter(\"DUMMY\"='X')\n<\/code><\/pre>\n<p>Just one more thing that is special with autotrace&#8230;<\/p>\n<h3>Conclusion<\/h3>\n<p>I don&#8217;t know exactly how cursor_sharing=force is managed. I thought that the literal replacement occurred before searching for parent cursor. Don&#8217;t hesitate to comment here if you know the &#8216;why&#8217; behind this behavior. My goal here was just to test what has to be done in order to have immediate effect of cursor_sharing change.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>By Franck Pachot . I usually don&#8217;t advice to set CURSOR_SHARING=FORCE but imagine your application requires it, you forgot it (or tried to do without) on migration and then everything is slow. You want to change it, but when does it take effect? New execution? New parsing? New session? EXACT I have the default value&hellip;&nbsp;<\/p>\n","protected":false},"author":27,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"neve_meta_sidebar":"","neve_meta_container":"","neve_meta_enable_content_width":"","neve_meta_content_width":0,"neve_meta_title_alignment":"","neve_meta_author_avatar":"","neve_post_elements_order":"","neve_meta_disable_header":"","neve_meta_disable_footer":"","neve_meta_disable_title":"","neve_meta_reading_time":"","_themeisle_gutenberg_block_has_review":false,"footnotes":""},"categories":[4133],"tags":[767],"class_list":["post-8402","post","type-post","status-publish","format-standard","category-database","tag-cursor-sharing"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v28.9 (Yoast SEO v28.9) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>When changing CURSOR_SHARING takes effect? - dbi services Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.dbi-services.com\/blog\/when-changing-cursor_sharing-takes-effect\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"When changing CURSOR_SHARING takes effect?\" \/>\n<meta property=\"og:description\" content=\"By Franck Pachot . I usually don&#8217;t advice to set CURSOR_SHARING=FORCE but imagine your application requires it, you forgot it (or tried to do without) on migration and then everything is slow. You want to change it, but when does it take effect? New execution? New parsing? New session? EXACT I have the default value&hellip;&nbsp;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.dbi-services.com\/blog\/when-changing-cursor_sharing-takes-effect\/\" \/>\n<meta property=\"og:site_name\" content=\"dbi services Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/dbiservices\/\" \/>\n<meta property=\"article:published_time\" content=\"2016-06-20T16:15:59+00:00\" \/>\n<meta name=\"author\" content=\"Oracle Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@dbiservices\" \/>\n<meta name=\"twitter:site\" content=\"@dbiservices\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Oracle Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/when-changing-cursor_sharing-takes-effect\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/when-changing-cursor_sharing-takes-effect\\\/\"},\"author\":{\"name\":\"Oracle Team\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#\\\/schema\\\/person\\\/bf7c7eb0bec165183207237c9d0ee1d5\"},\"headline\":\"When changing CURSOR_SHARING takes effect?\",\"datePublished\":\"2016-06-20T16:15:59+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/when-changing-cursor_sharing-takes-effect\\\/\"},\"wordCount\":277,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/#organization\"},\"keywords\":[\"cursor sharing\"],\"articleSection\":[\"Database\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/when-changing-cursor_sharing-takes-effect\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/when-changing-cursor_sharing-takes-effect\\\/\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/when-changing-cursor_sharing-takes-effect\\\/\",\"name\":\"When changing CURSOR_SHARING takes effect? - dbi services Blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#website\"},\"datePublished\":\"2016-06-20T16:15:59+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/when-changing-cursor_sharing-takes-effect\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/when-changing-cursor_sharing-takes-effect\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/when-changing-cursor_sharing-takes-effect\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"When changing CURSOR_SHARING takes effect?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/\",\"name\":\"dbi services Blog\",\"description\":\"#BeSharing\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/#organization\",\"name\":\"dbi services\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/09\\\/dbi-services-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/09\\\/dbi-services-logo.png\",\"width\":512,\"height\":512,\"caption\":\"dbi services\"},\"image\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/dbiservices\\\/\",\"https:\\\/\\\/x.com\\\/dbiservices\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/dbi-services\\\/\",\"https:\\\/\\\/www.youtube.com\\\/user\\\/dbiservices\"],\"description\":\"Swiss IT consulting and services company specialized in efficient data infrastructures and platforms: databases, application servers, cloud, DevOps, digitalization, analytics, data quality and monitoring. Headquartered in Del\u00e9mont with offices in Nyon, Basel, Bern and Zurich.\",\"email\":\"info@dbi-services.com\",\"telephone\":\"+41 32 422 96 00\",\"legalName\":\"dbi services SA\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#\\\/schema\\\/person\\\/bf7c7eb0bec165183207237c9d0ee1d5\",\"name\":\"Oracle Team\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/12\\\/oracle-square.png\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/12\\\/oracle-square.png\",\"contentUrl\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/12\\\/oracle-square.png\",\"caption\":\"Oracle Team\"},\"description\":\"Posts published under the Oracle Team account are collective contributions by the dbi services Oracle consultants. The practice covers the full Oracle Database lifecycle: architecture, migration and upgrade, high availability with RAC and Data Guard, backup and recovery, performance tuning, and engineered systems such as Oracle Database Appliance and Exadata. The team holds Oracle certifications up to Certified Master level and operates customer platforms under service level agreements.\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/author\\\/oracle-team\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"When changing CURSOR_SHARING takes effect? - dbi services Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.dbi-services.com\/blog\/when-changing-cursor_sharing-takes-effect\/","og_locale":"en_US","og_type":"article","og_title":"When changing CURSOR_SHARING takes effect?","og_description":"By Franck Pachot . I usually don&#8217;t advice to set CURSOR_SHARING=FORCE but imagine your application requires it, you forgot it (or tried to do without) on migration and then everything is slow. You want to change it, but when does it take effect? New execution? New parsing? New session? EXACT I have the default value&hellip;&nbsp;","og_url":"https:\/\/www.dbi-services.com\/blog\/when-changing-cursor_sharing-takes-effect\/","og_site_name":"dbi services Blog","article_publisher":"https:\/\/www.facebook.com\/dbiservices\/","article_published_time":"2016-06-20T16:15:59+00:00","author":"Oracle Team","twitter_card":"summary_large_image","twitter_creator":"@dbiservices","twitter_site":"@dbiservices","twitter_misc":{"Written by":"Oracle Team","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.dbi-services.com\/blog\/when-changing-cursor_sharing-takes-effect\/#article","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/when-changing-cursor_sharing-takes-effect\/"},"author":{"name":"Oracle Team","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/bf7c7eb0bec165183207237c9d0ee1d5"},"headline":"When changing CURSOR_SHARING takes effect?","datePublished":"2016-06-20T16:15:59+00:00","mainEntityOfPage":{"@id":"https:\/\/www.dbi-services.com\/blog\/when-changing-cursor_sharing-takes-effect\/"},"wordCount":277,"commentCount":1,"publisher":{"@id":"https:\/\/www.dbi-services.com\/#organization"},"keywords":["cursor sharing"],"articleSection":["Database"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.dbi-services.com\/blog\/when-changing-cursor_sharing-takes-effect\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.dbi-services.com\/blog\/when-changing-cursor_sharing-takes-effect\/","url":"https:\/\/www.dbi-services.com\/blog\/when-changing-cursor_sharing-takes-effect\/","name":"When changing CURSOR_SHARING takes effect? - dbi services Blog","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/#website"},"datePublished":"2016-06-20T16:15:59+00:00","breadcrumb":{"@id":"https:\/\/www.dbi-services.com\/blog\/when-changing-cursor_sharing-takes-effect\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.dbi-services.com\/blog\/when-changing-cursor_sharing-takes-effect\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.dbi-services.com\/blog\/when-changing-cursor_sharing-takes-effect\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.dbi-services.com\/blog\/"},{"@type":"ListItem","position":2,"name":"When changing CURSOR_SHARING takes effect?"}]},{"@type":"WebSite","@id":"https:\/\/www.dbi-services.com\/blog\/#website","url":"https:\/\/www.dbi-services.com\/blog\/","name":"dbi services Blog","description":"#BeSharing","publisher":{"@id":"https:\/\/www.dbi-services.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.dbi-services.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.dbi-services.com\/#organization","name":"dbi services","url":"https:\/\/www.dbi-services.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2026\/09\/dbi-services-logo.png","contentUrl":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2026\/09\/dbi-services-logo.png","width":512,"height":512,"caption":"dbi services"},"image":{"@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/dbiservices\/","https:\/\/x.com\/dbiservices","https:\/\/www.linkedin.com\/company\/dbi-services\/","https:\/\/www.youtube.com\/user\/dbiservices"],"description":"Swiss IT consulting and services company specialized in efficient data infrastructures and platforms: databases, application servers, cloud, DevOps, digitalization, analytics, data quality and monitoring. Headquartered in Del\u00e9mont with offices in Nyon, Basel, Bern and Zurich.","email":"info@dbi-services.com","telephone":"+41 32 422 96 00","legalName":"dbi services SA"},{"@type":"Person","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/bf7c7eb0bec165183207237c9d0ee1d5","name":"Oracle Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/12\/oracle-square.png","url":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/12\/oracle-square.png","contentUrl":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/12\/oracle-square.png","caption":"Oracle Team"},"description":"Posts published under the Oracle Team account are collective contributions by the dbi services Oracle consultants. The practice covers the full Oracle Database lifecycle: architecture, migration and upgrade, high availability with RAC and Data Guard, backup and recovery, performance tuning, and engineered systems such as Oracle Database Appliance and Exadata. The team holds Oracle certifications up to Certified Master level and operates customer platforms under service level agreements.","url":"https:\/\/www.dbi-services.com\/blog\/author\/oracle-team\/"}]}},"_links":{"self":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/8402","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/users\/27"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/comments?post=8402"}],"version-history":[{"count":0,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/8402\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/media?parent=8402"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/categories?post=8402"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/tags?post=8402"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}