{"id":1017,"date":"2006-07-13T12:00:00","date_gmt":"2006-07-13T12:00:00","guid":{"rendered":"http:\/\/orcldoug.com\/blog\/?p=1017"},"modified":"2006-07-13T12:00:00","modified_gmt":"2006-07-13T12:00:00","slug":"alter-table-move-and-table-stats","status":"publish","type":"post","link":"http:\/\/orcldoug.com\/blog\/2006\/07\/13\/alter-table-move-and-table-stats\/","title":{"rendered":"alter table &#8230; move and table stats"},"content":{"rendered":"<p><a href=\"http:\/\/www.dizwell.com\/\">Howard Rogers<\/a> left a comment on <a href=\"http:\/\/18.133.199.212\/?p=1016\">my last blog<\/a>, showing an example of using alter table &#8230; move on a 10gR2 database on Linux. In his example, unlike mine, the table rebuild did <strong>not<\/strong> nullify the table&#8217;s statistics. I admit I was surprised myself when I ran my example yesterday so I was concerned that I&#8217;d messed up my test somewhere, despite being careful.<\/p>\n<p>This morning I&#8217;ve tried the same test by creating a script containing all of the commands from the previous blog and ran it on two different databases, one 9.2.0.6 and one 10.2.0.1, both running on Solaris 8.<\/p>\n<p><strong>Here&#8217;s the 9.2 output<\/strong><\/p>\n<p><\/p>\n<pre>SQL&gt; create user test identified by test<br\/>  2  default tablespace data<br\/>  3  temporary tablespace temp;<br\/><p><\/p><br\/>User created.<br\/><p><\/p><br\/>SQL&gt; grant connect, resource to test;<br\/><p><\/p><br\/>Grant succeeded.<br\/><p><\/p><br\/>SQL&gt; alter user test quota unlimited on data;<br\/><p><\/p><br\/>User altered.<br\/><p><\/p><br\/>SQL&gt; connect test\/test<br\/>Connected.<br\/>SQL&gt; create table test (long_string varchar2(2000));<br\/><p><\/p><br\/>Table created.<br\/><p><\/p><br\/>SQL&gt; begin<br\/>  2  \t     for ctr in 1 .. 10000 loop<br\/>  3  \t\t     insert into test values (to_char(ctr));<br\/>  4  \t     end loop;<br\/>  5  end;<br\/>  6  \/<br\/><p><\/p><br\/>PL\/SQL procedure successfully completed.<br\/><p><\/p><br\/>SQL&gt; commit;<br\/><p><\/p><br\/>Commit complete.<br\/><p><\/p><br\/>SQL&gt; analyze table test compute statistics;<br\/><p><\/p><br\/>Table analyzed.<br\/><p><\/p><br\/>SQL&gt; select table_name, num_rows, chain_cnt from user_tables;<br\/><p><\/p><br\/>TABLE_NAME                                           NUM_ROWS    CHAIN_CNT                            <br\/>------------------------------ ---------- ----------                            <br\/>TEST                                10000                   0                            <br\/><p><\/p><br\/>SQL&gt; update test set long_string = lpad(long_string, 500);<br\/><p><\/p><br\/>10000 rows updated.<br\/><p><\/p><br\/>SQL&gt; commit;<br\/><p><\/p><br\/>Commit complete.<br\/><p><\/p><br\/>SQL&gt; analyze table test compute statistics;<br\/><p><\/p><br\/>Table analyzed.<br\/><p><\/p><br\/>SQL&gt; select table_name, num_rows, chain_cnt from user_tables;<br\/><p><\/p><br\/>TABLE_NAME                       NUM_ROWS  CHAIN_CNT                            <br\/>------------------------------ ---------- ----------                            <br\/>TEST                                10000       9983                            <br\/><p><\/p><br\/>SQL&gt; alter table test move initrans 6;<br\/><p><\/p><br\/>Table altered.<br\/><p><\/p><br\/>SQL&gt; select table_name, num_rows, chain_cnt from user_tables;<br\/><p><\/p><br\/>TABLE_NAME                       NUM_ROWS  CHAIN_CNT                            <br\/>------------------------------ ---------- ----------                            <br\/>TEST                                                                            <br\/><p><\/p><br\/>SQL&gt; analyze table test compute statistics;<br\/><p><\/p><br\/>Table analyzed.<br\/><p><\/p><br\/>SQL&gt; select table_name, num_rows, chain_cnt from user_tables;<br\/><p><\/p><br\/>TABLE_NAME                       NUM_ROWS  CHAIN_CNT                            <br\/>------------------------------ ---------- ----------                            <br\/>TEST                                10000          0                            <br\/><p><\/p><br\/><\/pre>\n<p><strong>Here&#8217;s the 10.2 output<\/strong><\/p>\n<pre><br\/><p><\/p><br\/>SYS @ CMDBD &gt; create user test identified by test<br\/>  2  default tablespace tools<br\/>  3  temporary tablespace temp;<br\/><p><\/p><br\/>User created.<br\/><p><\/p><br\/>SYS @ CMDBD &gt; grant connect, resource to test;<br\/><p><\/p><br\/>Grant succeeded.<br\/><p><\/p><br\/>SYS @ CMDBD &gt; alter user test quota unlimited on tools;<br\/><p><\/p><br\/>User altered.<br\/><p><\/p><br\/>SYS @ CMDBD &gt; connect test\/test<br\/>Connected.<br\/>TEST @ CMDBD &gt; create table test (long_string varchar2(2000));<br\/><p><\/p><br\/>Table created.<br\/><p><\/p><br\/>TEST @ CMDBD &gt; begin<br\/>  2          for ctr in 1 .. 10000 loop<br\/>  3                  insert into test values (to_char(ctr));<br\/>  4          end loop;<br\/>  5  end;<br\/>  6  \/<br\/><p><\/p><br\/>PL\/SQL procedure successfully completed.<br\/><p><\/p><br\/>TEST @ CMDBD &gt; commit;<br\/><p><\/p><br\/>Commit complete.<br\/><p><\/p><br\/>TEST @ CMDBD &gt; analyze table test compute statistics;<br\/><p><\/p><br\/>Table analyzed.<br\/><p><\/p><br\/>TEST @ CMDBD &gt; select table_name, num_rows, chain_cnt from user_tables;<br\/><p><\/p><br\/>TABLE_NAME                       NUM_ROWS  CHAIN_CNT<br\/>------------------------------ ---------- ----------<br\/>TEST                                10000          0<br\/><p><\/p><br\/>TEST @ CMDBD &gt; update test set long_string = lpad(long_string, 500);<br\/><p><\/p><br\/>10000 rows updated.<br\/><p><\/p><br\/>TEST @ CMDBD &gt; commit;<br\/><p><\/p><br\/>Commit complete.<br\/><p><\/p><br\/>TEST @ CMDBD &gt; analyze table test compute statistics;<br\/><p><\/p><br\/>Table analyzed.<br\/><p><\/p><br\/>TEST @ CMDBD &gt; select table_name, num_rows, chain_cnt from user_tables;<br\/><p><\/p><br\/>TABLE_NAME                       NUM_ROWS  CHAIN_CNT<br\/>------------------------------ ---------- ----------<br\/>TEST                                10000       9999<br\/><p><\/p><br\/>TEST @ CMDBD &gt; alter table test move initrans 6;<br\/><p><\/p><br\/>Table altered.<br\/><p><\/p><br\/>TEST @ CMDBD &gt; select table_name, num_rows, chain_cnt from user_tables;<br\/><p><\/p><br\/>TABLE_NAME                       NUM_ROWS  CHAIN_CNT<br\/>------------------------------ ---------- ----------<br\/>TEST                                10000       9999<br\/><p><\/p><br\/>TEST @ CMDBD &gt; analyze table test compute statistics;<br\/><p><\/p><br\/>Table analyzed.<br\/><p><\/p><br\/>TEST @ CMDBD &gt; select table_name, num_rows, chain_cnt from user_tables;<br\/><p><\/p><br\/>TABLE_NAME                       NUM_ROWS  CHAIN_CNT<br\/>------------------------------ ---------- ----------<br\/>TEST                                10000          0<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Howard Rogers left a comment on my last blog, showing an example of using alter table &#8230; move on a 10gR2 database on Linux. In his example, unlike mine, the table rebuild did not nullify the table&#8217;s statistics. I admit I was surprised myself when I ran my example yesterday so I was concerned that&hellip; <a class=\"more-link\" href=\"http:\/\/orcldoug.com\/blog\/2006\/07\/13\/alter-table-move-and-table-stats\/\">Continue reading <span class=\"screen-reader-text\">alter table &#8230; move and table stats<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1017","post","type-post","status-publish","format-standard","hentry","category-uncategorized","entry"],"jetpack_featured_media_url":"","jetpack-related-posts":[{"id":1016,"url":"http:\/\/orcldoug.com\/blog\/2006\/07\/12\/table-reorgs-and-statistics\/","url_meta":{"origin":1017,"position":0},"title":"Table reorgs and statistics","date":"July 12, 2006","format":false,"excerpt":"While working on the ITL deadlock problem (which looks like it's been fixed by the initrans increase and table rebuild), the developers highlighted another table as hitting this problem in the past. When I investigated, I found that initrans had already been set to 6 so this had obviously happened\u2026","rel":"","context":"With 10 comments","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1062,"url":"http:\/\/orcldoug.com\/blog\/2006\/08\/21\/resumable-storage-allocation\/","url_meta":{"origin":1017,"position":1},"title":"Resumable Storage Allocation","date":"August 21, 2006","format":false,"excerpt":"At the moment I'm writing a short 9i\/10g New Features seminar for the developers at work. The idea is to run through lots of new features very quickly to see if anything lights their candle and they can then go off and investigate further afterwards.It occurred to me while I\u2026","rel":"","context":"With 9 comments","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":992,"url":"http:\/\/orcldoug.com\/blog\/2006\/06\/13\/production-call-out\/","url_meta":{"origin":1017,"position":2},"title":"Production Call-out","date":"June 13, 2006","format":false,"excerpt":"On Saturday morning, we ran into a problem on one of our 9.2.0.7 Production databases during an Extract, Transform and Load (ETL) batch process.I was called at 5:15am to look at a job that normally runs in a few minutes but had failed after 30 or 40 minutes when trying\u2026","rel":"","context":"With 4 comments","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1481,"url":"http:\/\/orcldoug.com\/blog\/2009\/04\/09\/diagnosing-locking-problems-using-ash-part-4\/","url_meta":{"origin":1017,"position":3},"title":"Diagnosing Locking Problems using ASH \u2013 Part 4","date":"April 9, 2009","format":false,"excerpt":"Some features in this post require a Diagnostics Pack license.No sooner had I finished part 3 with some conclusions than I thought of another example I should have included and then someone else made a comment in an email which suggested another. (Thanks, JB!) \"It's probably worth pointing out that\u2026","rel":"","context":"Similar post","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1019,"url":"http:\/\/orcldoug.com\/blog\/2006\/07\/14\/alter-table-move-and-table-stats-part-ii\/","url_meta":{"origin":1017,"position":4},"title":"alter table &#8230; move and table stats (part II)","date":"July 14, 2006","format":false,"excerpt":"Following up on another comment from Howard, I took the initrans change off the alter table ... move so that it was the most basic variation and then ran it on 8i, 9i and 10g. I've trimmed lots of the output this time, but I have the log files if\u2026","rel":"","context":"Similar post","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1562,"url":"http:\/\/orcldoug.com\/blog\/2010\/02\/17\/statistics-on-partitioned-tables-part-1\/","url_meta":{"origin":1017,"position":5},"title":"Statistics on Partitioned Tables &#8211; Part 1","date":"February 17, 2010","format":false,"excerpt":"If you've ever worked on large databases that use partitioned and subpartitioned tables, you'll be aware that there are significant challenges in maintaining up-to-date\/appropriate statistics. We've encountered a few problems at work recently and I decided it would be an idea to put together a series of posts covering the\u2026","rel":"","context":"With 11 comments","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"http:\/\/orcldoug.com\/blog\/wp-json\/wp\/v2\/posts\/1017","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/orcldoug.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/orcldoug.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/orcldoug.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/orcldoug.com\/blog\/wp-json\/wp\/v2\/comments?post=1017"}],"version-history":[{"count":0,"href":"http:\/\/orcldoug.com\/blog\/wp-json\/wp\/v2\/posts\/1017\/revisions"}],"wp:attachment":[{"href":"http:\/\/orcldoug.com\/blog\/wp-json\/wp\/v2\/media?parent=1017"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/orcldoug.com\/blog\/wp-json\/wp\/v2\/categories?post=1017"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/orcldoug.com\/blog\/wp-json\/wp\/v2\/tags?post=1017"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}