iSelfSchooling.com - Copyright © 1999-2007 iSelfSchooling.com  References  Job Openings  |  Secure Login
    Home  | Search more...  |  FREE Online VIDEO Oracle Training  |  Gift Store  |  Bookstore

   Unlimited access!   

    Oracle  Syntax  | Suggestions Your Contribution  |  FREE Legal Forms

 

Email2aFriend Homepage us! |  Bookmark   -  Copyright & User Agreement

Products/Services

 Vision/Mission

 Community Sharing

 Services

  Products

 Biography

 Contact Us

 FAQ

 Current News

 Website Traffic

 Bookstore

 FREE Training

 SQL

 PL/SQL

 Forms 

 Reports

 Other TOOLS

 Fundamentals

 Performance

 OEM

 Application Server

 Grid Control

 Articles

 Prepare for OCP

Oracle SYNTAX

 Oracle Functions

 Oracle Syntax

 Oracle 10g Syntax

  PL/SQL Syntax

UNIX and more...

 UNIX for DBAs

 LINUX for DBAs

 DB using PHP

  A+ Certification

 Basics of JAVA  

 Tips of  SEO

Finance/Jobs

 Financial Aid

 Skilled

 Oracle

 Jobs

  Magazine

More Training

 Q & Answers

 SQL-PL/SQL

 DBA

 Developer

 Important Notes

 Case Studies

 9i New Features

 10g New Features

 10g Qs/As

 Grid Control

 OracleAS # I

 OracleAS # II

  LDAP and OID

  HTTP Server

 Instructor-Led

  Virtual Hosts

 Community Sharing

More to know...

Acknowledgement**

 FREE Legal Forms

 Who is who

 Market Place

 University Directory

 Advisory Articles

 Links...

 

 

FREE Online Oracle Training for beginners and advanced - The most comprehensive Oracle tutorial

The authors do not guarantee or take any responsibility for the accuracy, or completeness of the information.

BASICS

SQL | PL/SQL

DEVELOPERS

FORMS 2 | REPORTS | Other TOOLS

DBAs

FUNDAMENTALS 2 | PERFORMANCE | OEM

ADVANCE

APPLICATION SERVER | GRID CONTROL | ARTICLES 2 3 4

Advanced - Articles I

Lesson 01 | Lesson 02 | Lesson 03 | Lesson 04 | Lesson 05 | Lesson 06 | Lesson 07 | Lesson 08 | Lesson 09 | Lesson 10 | Lesson 11 | Lesson 12 | Lesson 13 | Lesson 14 | Lesson 15 | Lesson 16 | Lesson 17 | Lesson 18 | Lesson 19 | Lesson 20 | Lesson 21 | Lesson 22 | Lesson 23 | Lesson 24 | Lesson 25 | Lesson 26 | Lesson 27 | Lesson 28 | Lesson 29 | Lesson 30 | Lesson 31 | Lesson 32 | Lesson 33 | Lesson 34 | Lesson 35 |

Lesson 08

‘The difference between what we do and what we are capable of doing would suffice to solve most of the world's problems.’ Gandhi

Application tuning in the Oracle 10g database

Introduction

To enhance Query Optimization, the OPTIMIZER_DYNAMIC_SAMPING is set to 2 by default.

Automatic PGA Memory Management is now enabled by default and PGA_AGGREGATE_TARGET is set to 20 percent. In order to disable the Automatic PGA Memory Management set the parameter to 0.

 

Gathering Statistics

On Oracle Database 10g, you can gather statistics on dictionary tables (both fixed and real) to get the best performance. You use the DBMS_STATS.GATHER_DATABASE_STATS procedure with GATHER_SYS argument set to TRUE or DBMS_STATS.GATHER_DICTIONARY_STATS. To use this, you should have the ANALYZE ANY DICTIONARY system privilege. For example:

SQL> BEGIN

DBMS_STATS.GATHER_DATABASE_STATS(options=’GATHER AUTO’);

END;

/ -- Note use GATHER only if you are using release 8i

Automatic Tuning Optimizer (ATO): When the optimizer is tuning a SQL statement using ATO, it is called Automatic SQL Tuning. To perform automatic SQL tuning, see the following hands-on.

 

Hands-On #1-Performing Automatic SQL tuning

Create a binding variable and then move your query into it.

SQL> VARIABLE my_query VARCHAR2(1000)

SQL> BEGIN

:my_query := ‘SELECT ename FROM iself.emp WHERE empno = 100;’

END;

/

Use the DBMS_SQLTUNE package to create a tuning task by calling the CREATE_TUNING_TASK function. This procedure creates an advisor task and sets its corresponding parameters according to the user-provided input arguments. To execute this you need one more binding variable to keep your task name.

SQL> VARIABLE my_task VARCHAR2(100)

SQL> BEGIN

:my_task := DBMS_SQLTUNE.create_tuning_task (

SQL_TEXT => :my_query,

BIND_LIST => SQL_BINDS(anydata.ConvertNumber(100)),

USER_NAME => ‘ISELF’,

SCOPE => ‘COMPREHENSIVE’,

TIME_LIMIT => 60,

TASK_NAME => ‘my_tuning_task’,

DESCRIPTION => ‘Query on EMP table …’);

END;

/

Invoke the EXECUTE_TUNING_TASK procedure to start the tuning process.

SQL> BEGIN

DBMS_SQLTUNE.execute_tuning_task (TASK_NAME=>:my_task);

END;

Call the REPORT_TUNING_TASK function to visualize the tuning results.

SQL> SQL> SELECT DBMS_SQLTUNE.report_tuning_task

(TASK_NAME=>:my_task)

FROM dual;

When the SQL Tuning Advisor recommends a SQL Profile, then create the SQL Profile by calling the ACCEPT_SQL_PROFILE function, which stores it in the data dictionary. You should have the CREATE ANY SQL PROFILE privilege.

SQL> VARIABLE my_profile VARCHAR2(1000)

SQL> BEGIN

:my_profile := DBMS_SQLTUNE.accept_sql_profile

(TASK_NAME => ’my_tuning_task’);

END;

/

SQL> SELECT :my_profile FROM dual;

 

Hands-On # 2-Advantage of MVIEW

Let see the advantage of creating mview.

Connect as the ISELF user.

SQL> CONNECT iself/schooling

Create a materialized view called my_mview using the EMP table. This view summarize department total salaries.

SQL> CREATE MATERIALIZED VIEW my_mview

BUILD IMMEDIATE

ENABLE QUERY REWRITE

AS SELECT deptno, SUM(sal) as salary

FROM EMP

GROUP BY deptno;

Gather statistics against the new materialized view.

SQL> BEGIN

DBMS_STATS.gather_table_stats(USER, ‘MY_MVIEW’);

END;

/

Query from new materialized view.

SQL> SELECT * FROM my_mview;

Execute EXPLAIN PLAN against the query in the previous step.

SQL> EXPLAIN PLAN FOR

SELECT deptno, SUM(sal) as salary

FROM EMP

GROUP BY deptno;

SQL> SELECT * FROM ( dbms_xplan.display );

Now, use the DBMS_MVIEW.EXPLAIN_REWRITE procedure against the query and the MY_MVIEW materialized view, and then query the REWRITE_TABLE. If you do not have REWRITE_TABLE, then run the utlxrw.sql script.

SQL> @$ORACLE_HOME/rdbms/admin/utlxrw.sql

SQL> BEGIN

DBMS_MVIEW.explain_rewrite (

‘SELECT deptno, SUM(sal) as salary FROM EMP GROUP BY deptno’,

‘ISELF.MY_MVIEW’, ‘This is my explain_rewrite practice…’);

END;

/

SQL> COL message FORMAT a35

SQL> SELECT message, original_cost, rewritten_cost

FROM rewrite_table;

 

 

 

“Violence as a way of achieving racial justice is both impractical and immoral. It is impractical because it is a descending spiral ending in destruction for all. It is immoral because it seeks to humiliate the opponent rather than win his understanding; it seeks to annihilate rather than to convert. Violence is immoral because it thrives on hatred rather than love.” Martin Luther King Jr.

Questions:

 

Questions on

Application tuning in the Oracle 10g database

Q: What is the OPTIMIZER_DYNAMIC_SAMPING setting default?

Q: How do you disable the Automatic PGA Memory Management?

Q: How do you gather statistics on dictionary tables in the Oracle 10g Database?

Q: What is the Automatic Tuning Optimizer (ATO)?

Q: How do you perform automatic SQL tuning?

Q: How do you use the DBMS_SQLTUNE package to create a tuning task by calling the CREATE_TUNING_TASK function?

Q: How do you use the EXECUTE_TUNING_TASK procedure to start the tuning process?

Q: How do you call the REPORT_TUNING_TASK function to visualize the tuning results?

Q: How do you store a SQL profile in the data dictionary?

 

 

 
 
Google
 
Web web site