{"id":7541,"date":"2016-05-17T18:51:03","date_gmt":"2016-05-17T16:51:03","guid":{"rendered":"https:\/\/www.dbi-services.com\/blog\/multitenant-dictionary-what-is-stored-only-in-cdbroot\/"},"modified":"2016-05-17T18:51:03","modified_gmt":"2016-05-17T16:51:03","slug":"multitenant-dictionary-what-is-stored-only-in-cdbroot","status":"publish","type":"post","link":"https:\/\/www.dbi-services.com\/blog\/multitenant-dictionary-what-is-stored-only-in-cdbroot\/","title":{"rendered":"Multitenant dictionary: what is stored only in CDB$ROOT?"},"content":{"rendered":"<h2>By Franck Pachot<\/h2>\n<p>.<br \/>\nMultitenant architecture is about dictionary separation. The idea is that all system metadata is stored only in CDB$ROOT so that space and upgrade time are optimized. Is it entirely true? let&#8217;s count the rows in the dictionary tables.<br \/>\n<!--more--><br \/>\nIn order to verify that, I&#8217;ve build a query that will count the rows from the dictionary tables, in CDB$ROOT and in PDB$SEED.<br \/>\nThe idea is to query DBA_OBJECTS for ORACLE_MAINTAINED=Y objects and call a function that run an &#8216;execute immediate&#8217; to do a &#8216;select count(*)&#8217;. Inline functions in 12<em>c<\/em> are great for that. Especially when I want to switch to another container for it. Note that I&#8217;m not 100% sure that it&#8217;s supported to switch to another container there but al least don&#8217;t forget to switch back to initial one.<br \/>\nAs I&#8217;m using some inline function, I&#8217;ve added one &#8216;hextoasc&#8217; that helps me to lookup into the dictionary cache for the presence of object (not related to this post) and I also check which table is in the bootstrap procedure (which hard codes some dictionary metadata into row cache before they are available through buffer cache).<\/p>\n<p>So here is the query:<\/p>\n<pre><code>\nwith function countrows(con_name varchar2,name varchar2) return number as\n n number; \n saved_con_name varchar2(128);\nbegin\n saved_con_name:=sys_context('userenv','con_name');\n execute immediate 'alter session set container='||con_name;\n execute immediate 'select count(*) from \"'||name||'\"' into n;\n execute immediate 'alter session set container='||saved_con_name;\n return n;\nexception when others then\n execute immediate 'alter session set container='||saved_con_name;\n return null;\nend;\nfunction hex2asc(s varchar2) return varchar2 as r varchar2(32000);\nbegin\n for i in 1..length(s)\/2\n  loop\n   exit when substr(s,2*i-1,2)='00';\n   r:=r||chr(to_number(substr(s,2*i-1,2),'XX'));\n  end loop;\n  return r;\nend; \nselect v.*\n,(select count(*) from v$rowcache_parent where key like '00%' and hex2asc(substr(key,13)||'00') like object_name||'%' and existent='Y' and con_id=1) rowcache_entries\n,(select substr(sql_text,1,30) from bootstrap$ where sql_text like '%TABLE '||object_name||'(%') bootstrap\nfrom (\nselect object_name,countrows('PDB$SEED',object_name) SEED_COUNT,countrows('CDB$ROOT',object_name) ROOT_COUNT\nfrom user_objects where object_type='TABLE' and oracle_maintained='Y' and object_name like '%$'\n) v \nwhere root_count&gt;0 order by seed_count desc, root_count desc;\n\/\n<\/code><\/pre>\n<p>And the first rows of the result where sorting those that have lot of lines in PDB$SEED first:<\/p>\n<pre><code>\nOBJECT_NAME                    SEED_COUNT ROOT_COUNT                        ROWCACHE_ENTRIES BOOTSTRAP                    \n------------------------------ ---------- ---------- --------------------------------------- ------------------------------\nDEPENDENCY$                        162253     162180                                       2                               \nCOL$                               111623     111663                                       2 CREATE TABLE COL$(\"OBJ#\" NUMBE\nOBJ$                                91511      91721                                       2 CREATE TABLE OBJ$(\"OBJ#\" NUMBE\nOBJAUTH$                            45085      45084                                       2                               \nHIST_HEAD$                          30585      50516                                       2                               \nACCESS$                             27351     109485                                       2                               \nKOTAD$                              25927      27456                                       2                               \nJAVASNM$                            25073      25073                                       2                               \nHISTGRM$                            22653      72890                                       2                               \nSETTINGS$                           19872      52936                                       2                               \nSOURCE$                             17608     327589                                       2                               \nATTRIBUTE$                          13975      13975                                       2                               \nPARAMETER$                          11785      11785                                       2                               \nCCOL$                               11362      11400                                       2 CREATE TABLE CCOL$(\"CON#\" NUMB\nCON$                                 9648       9686                                       2 CREATE TABLE CON$(\"OWNER#\" NUM\nCDEF$                                9493       9685                                       2 CREATE TABLE CDEF$(\"CON#\" NUMB\nMETASCRIPTFILTER$                    7365       7365                                       2                               \nIDL_SB4$                             7288      17787                                       2                               \nICOL$                                6432       6432                                       2 CREATE TABLE ICOL$(\"OBJ#\" NUMB\nIDL_UB1$                             6290      53505                                       2                               \nIDL_UB2$                             5931      13029                                       2                               \nOID$                                 5119       6574                                       2                               \nIND$                                 4264       4264                                       2 CREATE TABLE IND$(\"OBJ#\" NUMBE\n<\/code><\/pre>\n<p>You see immediately that the largest metadata, which is the source of the stored procedures, in SOURCE$, is mostly stored only in CDB$ROOT. For space efficiency this is good.<\/p>\n<p>However you can see that COL$ and TAB$ have same number of rows in CDB$ROOT and in PDB, which is not exactly what is described in the oracle documentation.<\/p>\n<p>And tables such as DEPENDENCY$, managing dependency among objects, is still huge in the PDB. Dependencies are managed at that level.<\/p>\n<p>This explain why it still takes time to upgrade or patch a PDB when the CDB has been upgraded or patched. There is not only the metadata\/data links to verify. There is still some DDL to run to maintain the pluggable database dictionary.<\/p>\n<p>This is not exactly what is documented in <a href=\"https:\/\/docs.oracle.com\/database\/121\/CNCPT\/cdbovrvw.htm#CNCPT89242\">https:\/\/docs.oracle.com\/database\/121\/CNCPT\/cdbovrvw.htm#CNCPT89242<\/a>:<br \/>\n<em>Fewer database patches and upgrades<br \/>\nIt is easier to apply a patch to one database than to 100 databases, and to upgrade one database than to upgrade 100 databases.<\/em><\/p>\n<p>But we can expect that this will be improved in further releases.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>By Franck Pachot . Multitenant architecture is about dictionary separation. The idea is that all system metadata is stored only in CDB$ROOT so that space and upgrade time are optimized. Is it entirely true? let&#8217;s count the rows in the dictionary tables.<\/p>\n","protected":false},"author":27,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[229],"tags":[220,64,96,66,223],"type_dbi":[],"class_list":["post-7541","post","type-post","status-publish","format-standard","hentry","category-database-administration-monitoring","tag-cdb","tag-multitenant","tag-oracle","tag-pdb","tag-pluggable-databases"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.2 (Yoast SEO v27.2) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Multitenant dictionary: what is stored only in CDB$ROOT? - dbi 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\/multitenant-dictionary-what-is-stored-only-in-cdbroot\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Multitenant dictionary: what is stored only in CDB$ROOT?\" \/>\n<meta property=\"og:description\" content=\"By Franck Pachot . Multitenant architecture is about dictionary separation. The idea is that all system metadata is stored only in CDB$ROOT so that space and upgrade time are optimized. Is it entirely true? let&#8217;s count the rows in the dictionary tables.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.dbi-services.com\/blog\/multitenant-dictionary-what-is-stored-only-in-cdbroot\/\" \/>\n<meta property=\"og:site_name\" content=\"dbi Blog\" \/>\n<meta property=\"article:published_time\" content=\"2016-05-17T16:51:03+00:00\" \/>\n<meta name=\"author\" content=\"Oracle Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\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\/multitenant-dictionary-what-is-stored-only-in-cdbroot\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/multitenant-dictionary-what-is-stored-only-in-cdbroot\/\"},\"author\":{\"name\":\"Oracle Team\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/66ab87129f2d357f09971bc7936a77ee\"},\"headline\":\"Multitenant dictionary: what is stored only in CDB$ROOT?\",\"datePublished\":\"2016-05-17T16:51:03+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/multitenant-dictionary-what-is-stored-only-in-cdbroot\/\"},\"wordCount\":414,\"commentCount\":0,\"keywords\":[\"CDB\",\"multitenant\",\"Oracle\",\"PDB\",\"Pluggable Databases\"],\"articleSection\":[\"Database Administration &amp; Monitoring\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.dbi-services.com\/blog\/multitenant-dictionary-what-is-stored-only-in-cdbroot\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/multitenant-dictionary-what-is-stored-only-in-cdbroot\/\",\"url\":\"https:\/\/www.dbi-services.com\/blog\/multitenant-dictionary-what-is-stored-only-in-cdbroot\/\",\"name\":\"Multitenant dictionary: what is stored only in CDB$ROOT? - dbi Blog\",\"isPartOf\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#website\"},\"datePublished\":\"2016-05-17T16:51:03+00:00\",\"author\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/66ab87129f2d357f09971bc7936a77ee\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/multitenant-dictionary-what-is-stored-only-in-cdbroot\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.dbi-services.com\/blog\/multitenant-dictionary-what-is-stored-only-in-cdbroot\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/multitenant-dictionary-what-is-stored-only-in-cdbroot\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Accueil\",\"item\":\"https:\/\/www.dbi-services.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Multitenant dictionary: what is stored only in CDB$ROOT?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#website\",\"url\":\"https:\/\/www.dbi-services.com\/blog\/\",\"name\":\"dbi Blog\",\"description\":\"\",\"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\":\"Person\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/66ab87129f2d357f09971bc7936a77ee\",\"name\":\"Oracle Team\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/secure.gravatar.com\/avatar\/f711f7cd2c9b09bf2627133755b569fb5be0694810cfd33033bdd095fedba86d?s=96&d=mm&r=g\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/f711f7cd2c9b09bf2627133755b569fb5be0694810cfd33033bdd095fedba86d?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/f711f7cd2c9b09bf2627133755b569fb5be0694810cfd33033bdd095fedba86d?s=96&d=mm&r=g\",\"caption\":\"Oracle Team\"},\"url\":\"https:\/\/www.dbi-services.com\/blog\/author\/oracle-team\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Multitenant dictionary: what is stored only in CDB$ROOT? - dbi 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\/multitenant-dictionary-what-is-stored-only-in-cdbroot\/","og_locale":"en_US","og_type":"article","og_title":"Multitenant dictionary: what is stored only in CDB$ROOT?","og_description":"By Franck Pachot . Multitenant architecture is about dictionary separation. The idea is that all system metadata is stored only in CDB$ROOT so that space and upgrade time are optimized. Is it entirely true? let&#8217;s count the rows in the dictionary tables.","og_url":"https:\/\/www.dbi-services.com\/blog\/multitenant-dictionary-what-is-stored-only-in-cdbroot\/","og_site_name":"dbi Blog","article_published_time":"2016-05-17T16:51:03+00:00","author":"Oracle Team","twitter_card":"summary_large_image","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\/multitenant-dictionary-what-is-stored-only-in-cdbroot\/#article","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/multitenant-dictionary-what-is-stored-only-in-cdbroot\/"},"author":{"name":"Oracle Team","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/66ab87129f2d357f09971bc7936a77ee"},"headline":"Multitenant dictionary: what is stored only in CDB$ROOT?","datePublished":"2016-05-17T16:51:03+00:00","mainEntityOfPage":{"@id":"https:\/\/www.dbi-services.com\/blog\/multitenant-dictionary-what-is-stored-only-in-cdbroot\/"},"wordCount":414,"commentCount":0,"keywords":["CDB","multitenant","Oracle","PDB","Pluggable Databases"],"articleSection":["Database Administration &amp; Monitoring"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.dbi-services.com\/blog\/multitenant-dictionary-what-is-stored-only-in-cdbroot\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.dbi-services.com\/blog\/multitenant-dictionary-what-is-stored-only-in-cdbroot\/","url":"https:\/\/www.dbi-services.com\/blog\/multitenant-dictionary-what-is-stored-only-in-cdbroot\/","name":"Multitenant dictionary: what is stored only in CDB$ROOT? - dbi Blog","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/#website"},"datePublished":"2016-05-17T16:51:03+00:00","author":{"@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/66ab87129f2d357f09971bc7936a77ee"},"breadcrumb":{"@id":"https:\/\/www.dbi-services.com\/blog\/multitenant-dictionary-what-is-stored-only-in-cdbroot\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.dbi-services.com\/blog\/multitenant-dictionary-what-is-stored-only-in-cdbroot\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.dbi-services.com\/blog\/multitenant-dictionary-what-is-stored-only-in-cdbroot\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Accueil","item":"https:\/\/www.dbi-services.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Multitenant dictionary: what is stored only in CDB$ROOT?"}]},{"@type":"WebSite","@id":"https:\/\/www.dbi-services.com\/blog\/#website","url":"https:\/\/www.dbi-services.com\/blog\/","name":"dbi Blog","description":"","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":"Person","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/66ab87129f2d357f09971bc7936a77ee","name":"Oracle Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/f711f7cd2c9b09bf2627133755b569fb5be0694810cfd33033bdd095fedba86d?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/f711f7cd2c9b09bf2627133755b569fb5be0694810cfd33033bdd095fedba86d?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/f711f7cd2c9b09bf2627133755b569fb5be0694810cfd33033bdd095fedba86d?s=96&d=mm&r=g","caption":"Oracle Team"},"url":"https:\/\/www.dbi-services.com\/blog\/author\/oracle-team\/"}]}},"_links":{"self":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/7541","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=7541"}],"version-history":[{"count":0,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/7541\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/media?parent=7541"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/categories?post=7541"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/tags?post=7541"},{"taxonomy":"type","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/type_dbi?post=7541"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}