11.07.2015 Views

Oracle Database 11 g - Online Public Access Catalog

Oracle Database 11 g - Online Public Access Catalog

Oracle Database 11 g - Online Public Access Catalog

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER 4 ■ PERFORMANCE MANAGEMENT 201SQL> exec sys.dbms_stats.gather_table_stats(null,'customers',method_opt => 'for all columns size skewonlyfor columns (cust_state_province,country_id)skewonly')You specify the new column group you want to create by using the for columns clause. Theprocedure will both create the new column group as well as gather statistics on that group in asingle step.Deleting Extended StatisticsYou can remove any extended statistics you created by executing the drop_extended_statisticsprocedure, as shown in the following example:SQL> exec dbms_stats.drop_extended_stats(null,'customers',-'(country, state)');PL/SQL procedure successfully completed.SQL>You can use the drop_extended_statistics procedure for removing any extended statisticsthat you created for a function on a column.Expression Statistics for Functions and ExpressionsAnother area where the cost optimizer has trouble making true selectivity estimates is forcolumns to which you apply a function or an expression. For example, it’s common to use theupper and lower functions when using columns such as LAST_NAME and FIRST_NAME in a queryexpression, as shown in this example.SQL> select count(*)from employeeswhere lower(state) ='tx';Because of the application of a function to the state column, the optimizer can’t get accurateestimates of the selectivity of that column. In <strong>Oracle</strong> <strong>Database</strong> <strong>11</strong>g, you let the optimizerget better selectivity estimates by gathering expression statistics on the expression function.Suppose that the users input a value for the last name of the customers in uppercase. Youcan then create extended statistics on the expression UPPER (last_name) so the optimizer canget the correct count of the number of rows:SQL> exec dbms_stats.create_extended_stats -(null,' customers','(lower(cust_state_province))')As with the column groups, you can both create new extension statistics and gather statisticsat the same time by using the DBMS_STATS package, as shown in this example:SQL> exec dbms_stats.gather_table_stats (null,'customers_obe',-> method_opt => 'for all columns size skewonly for –> columns (upper(last_name)) -> skewonly');

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!