oracle11g - How Oracle update statistics data? -


oracle instance version: "oracle database 11g enterprise edition release 11.2.0.1.0 - 64bit production"

  • create new table[ord], nothing in table, use [select * ord] check statistics, cost 2
  • we insert 1000 records [ord] table , execute following script gather statistics, cost 9

    exec dbms_stats.gather_table_stats('corebm','ord',degree => 4,estimate_percent => null,method_opt => 'for columns',cascade => true);

  • then clear data in [ord] table([delete ord]), ensure changes committed, execute [exec dbms_stats.gather_table_stats(...)] again gather statistics, see cost still 9 different expecting 2

after data in [ord] table removed,and gathered statistics information, not understand why cost of [ord] table still 9 there nothing in table.

assuming query doing full scan of table, means has read every block high water mark of table. high water mark not reset when simple delete of data-- oracle assumes insert more data in future not incur cost of releasing extents delete data need reacquire them shortly thereafter. means, though full table scan costly when have 1000 rows of data when subsequently have 0 rows of data same high water mark. expect cost same after running delete.

if want reset high water mark, can truncate table rather deleting data. isn't used sort of proof of concept.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -