01.09.2016 Views

Beginning Oracle Database 11g Administration From Novice to Professional

Create successful ePaper yourself

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

390<br />

CHAPTER 17 SQL TUNING<br />

It is my firm belief that most scheduled statistics- gathering jobs do not cause much<br />

harm only because (most) changes in the statistics were insignificant as far as the<br />

optimizer is concerned—meaning that it was an exercise in futility. 6<br />

There are some statistics about your data that can be left unchanged for a long time,<br />

possibly forever; there are some statistics that need <strong>to</strong> be changed periodically; and<br />

there are some statistics that need <strong>to</strong> be changed constantly....The biggest problem is<br />

that you need <strong>to</strong> understand the data. 7<br />

<strong>Beginning</strong> with <strong>Oracle</strong> 10g, statistics are au<strong>to</strong>matically collected by a job called<br />

that runs during a nightly maintenance window; this default strategy<br />

may work for many databases. The procedures in the package can be used<br />

<strong>to</strong> create a cus<strong>to</strong>m strategy. Complete details of the package can be found in<br />

<strong>Oracle</strong> <strong>Database</strong> <strong>11g</strong> PL/SQL Packages and Types Reference, which can be freely searched<br />

and downloaded at . Here is a representative list of the available<br />

procedures:<br />

and procedures can be used <strong>to</strong> enable and disable the<br />

job, respectively. The procedure can be used <strong>to</strong> run the<br />

job immediately.<br />

procedures can be used <strong>to</strong> manually gather statistics. For<br />

example, can be used <strong>to</strong> gather statistics for a single table, and<br />

can be used <strong>to</strong> gather statistics for all the indexes and tables in<br />

a schema.<br />

procedures can be used <strong>to</strong> delete statistics.<br />

procedures can be used <strong>to</strong> copy the statistics <strong>to</strong> a special table.<br />

can be used <strong>to</strong> import desired statistics. For example, statistics can<br />

be exported from a production database and imported in<strong>to</strong> a development database;<br />

this ensures that both databases use the same query execution plans.<br />

job retains previous statistics. The procedures<br />

can be used <strong>to</strong> res<strong>to</strong>re statistics from a previous point in time. The default<br />

retention period used by the is 31 days; this can be changed by<br />

using the procedure.<br />

procedures can be used <strong>to</strong> lock statistics and prevent them from<br />

being overwritten. Oddly enough, locking statistics can be a useful practice not<br />

only when data is static, but also when it is volatile.<br />

6. Wolfgang Breitling in the Journal of the Northern California <strong>Oracle</strong> Users Group<br />

7. Jonathan Lewis in the Journal of Northern California <strong>Oracle</strong> Users Group

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

Saved successfully!

Ooh no, something went wrong!