0% found this document useful (0 votes)
40 views

Oratips: Oracle 'S Approach To Performance Tuning, Part 1

Uploaded by

arulkumaranb
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views

Oratips: Oracle 'S Approach To Performance Tuning, Part 1

Uploaded by

arulkumaranb
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

ORAtips4On Database

Page 

January 2006 Volume II Issue 1

Oracle ’s Approach to Performance Tuning, Part 1


®

By Darrick Addison

Editor’s Note: You would not drive formance goals, as well as goals • Redo log setup problems
a car in need of service nor play an for the future.
out of tune piano? In his first ORAtips • Serialization of data blocks in the
article, a two part series, Darrick • Get a full set of operating system, buffer cache due to lack of free
Addison brings home the point that database, and application sta- lists, free list groups, transaction
your biggest Oracle investment, the tistics from the system when the slots (INITRANS), or shortage of
Oracle database, needs regular care performance is both good and rollback segments.
and feeding to run at maximum bad.
efficiency and peak performance. • Long full table scans
Darrick discusses the pros and cons • Sanity-check the operating sys-
of Oracle’s new approach for 10g tems of all machines involved • In disk sorting
tuning, identifying no less than 17 with user performance. By san-
problematic queries, and answers ity-checking the operating sys- • High amounts of recursive (SYS)
the questions “what do I look for and tem, you look for hardware or SQL
how do I make it better?” operating system resources that
are fully utilized. • Schema errors and Optimizer
Introduction problems
Performance tuning is a broad and
complex topic area when it comes to • Use of non-standard initializa-
Oracle databases. Two of the big- tion parameters
gest questions faced by your aver-
age DBA concern where to start and 3. Build a conceptual model of what
what to do. All you may know is that Two of the biggest is happening on the system, using
someone reports a problem about a the symptoms as clues to under-
slow or poor performing applica- questions faced by stand what caused the perfor-
tion or query. Where do you even mance problems.
begin to start when faced with this your average DBA
situation? Oracle’s emphasis on this 4. Propose a series of remedy actions
particular methodology changed concern where to and the anticipated response of
when Oracle10g was released. The the system, and then apply them
approach has gone from top-down in start and what to do. in the order that can benefit the
8i and 9i to that of following prin- application the most. A golden
ORAtipsJournal

ciples in 10g. rule in performance work is that


you only change one thing at a
The performance-tuning guide for time and then measure the differ-
Oracle10g (Release 2) identifies the ences.
overall process as The Oracle Per- 2. Check for the top ten most com-
formance Improvement Method. The mon mistakes with Oracle, and 5. Validate that the changes made
steps have been expanded, but over- determine if any of these are like- have had the desired effect, and
all, remain the same. ly to be the problem. List these see if the user’s perception of per-
symptoms for later analysis. formance has improved.
1. Perform the following initial
standard checks: • Bad connection management 6. Repeat the last three steps until
performance goals are met or
• Get candid feedback from users. • Bad use of cursors and the shared become impossible due to other
Identify the performance proj- pool constraints.
ect’s scope and subsequent per-
• Getting database I/O wrong

ORAtips.com ORAtips © 2006 Klee Associates, Inc.


ORAtips4On Database
Page 

January 2006 Volume II Issue 1

The Change Is Part of the 4. Avoid use of indexes on col- ate (partitioning is an extra
Problem umns contained in the WHERE cost feature).
The change from a top-down struc- clause.
tured approach to a principle-based 16. Use literals in the WHERE
“make it stop hurting” one is part 5. Avoid joining too many tables. clause (use bind variables).
of the problem. Gathering statistics
is obviously important, because how 6. Monitor V$SESSION_LON- 17. Keep statistics up to date.
would you know if you have improved GOPS to detect long running
(or worsened) the problem? To some operations. The list overall is thorough and
degree with either approach, you are accurate.
left with the original two questions: 7. Use hints as appropriate.
what do I look for, and how do I Note: Step 9, referring to the use of
make it better? 8. Use the SHARED_CURSOR the Rule-based optimizer, may cause
parameter. a reliance or dependency on a feature
What would help the novice tuner Oracle has identified as a future item
is a list of items or areas to analyze 9. Use the Rule-based optimizer if to be deprecated.
(configure, diagnose, and tune) in it is better than the Cost-based
each of the following: optimizer. Using Bind Variables
On any number of DBA help-type
• Tuning the Buffer Cache 10. Avoid unnecessary sorting. Web sites, a frequently seen bit of
• Tuning the Redo Log Buffer advice is to use bind variables, but
• Tuning the Shared Pool Memory 11. Monitor index browning (due rarely are the steps or instructions
• Tuning the Program Global Area to deletions; rebuild as neces- for this step included. Figure 1 illus-
• Optimizing Data Storage sary). trates a simple method for creating
• Optimizing Table spaces and using a bind variable.
• Tuning Undo Segments 12. Use compound indexes with
• Detecting Lock Contention care (do not repeat columns). Figures 2 and 3 compare querying
• Tuning SQL for employee ID and name with and
13. Monitor query statistics. without the bind variable (with the
These areas pretty much cover the output turned off using trace only).
Oracle RDBMS and instance from 14. Use different table spaces for
top to bottom. tables and indexes (as a gen- Okay, so the difference is not that
eral rule; this is old-school great (the cost went from 3 to 2), but
Listed below are guidelines to somewhat, but the main point this was a small example. The main
assist you in avoiding common mis- is reduce I/O contention). point of the previous section is using
takes and bad coding. and understanding bind variables.
15. Use table partitioning (and None of these steps is especially dif-
ORAtipsJournal

17 Tips for Avoiding local indexes) when appropri- ficult to perform or implement. For
Problematic Queries
These tips provide a solid founda- SQL> variable department_id number
tion for two outcomes: making a SQL SQL> begin
statement perform better, and deter- 2 :department_id := 80;
mining that nothing else can be done 3 end;
in this regard. 4/

The 17 tips are as follow: PL/SQL procedure successfully completed.

1. Avoid Cartesian products. SQL> print department_id

2. Avoid full table scans on large DEPARTMENT_ID


tables. -------------
80
3. Use SQL standards and conven-
tions to reduce parsing. Figure 1: Creating Bind Variables

ORAtips.com ORAtips © 2006 Klee Associates, Inc.


ORAtips4On Database
Page 

January 2006 Volume II Issue 1

Oracle programmers used to using


the “tableA.column_name = tab-
leB.column_name” format for joins,
moving to the use of natural joins
saves quite a bit of typing, plus there
is the benefit of having key column
names match up. As shown, some
measures may not have a big impact,
but every little bit helps to improve
performance.

DataFactory
The purpose of DataFactory is to
“quickly create meaningful test data
for multiple database platforms.”

Editor’s Note: DataFactory is trial


freeware from Quest‚ Software, the
same folks that created TOAD.

Creating Tutorial Objects


An excellent way to get to know
the application is to use its tutorial
objects, which includes: Figure 2: Querying Without a Bind Variable

• Create a project

• Create tables in a schema

• Run a script to load data

After starting DataFactory, you


can start the tutorial. The instruc-
tions on how to load and for help are
in HTML files.

Prior to creating the tables, you


ORAtipsJournal

may want to create a separate sche-


ma in your database.

Figure 3: Querying Using a Bind Variable

ORAtips.com ORAtips © 2006 Klee Associates, Inc.


ORAtips4On Database
Page 

January 2006 Volume II Issue 1

Figure 4: DataFactory – Create Tutorial Objects

To do this, use the navigation path:


Tools > Create Tutorial Objects as
shown in Figure 4 to execute the fol-
lowing steps.

Step 1: Start the Tutorial Setup Wiz-


Figure 5: Tutorial Setup Wizard
ard as shown in Figure 5.

Step 2: Once finished, a list of tables


appears as in Figure 6.

Step 3: Upon creation, DataFac-


tory will display a success window
(Figure 7).

Step 4: The project folder appears


in the left frame (Figure 8).

The purpose of
DataFactory is to
ORAtipsJournal

“quickly create
meaningful test
Figure 6: List of Tutorial Objects Created
data for multiple
database
platforms.”

Figure 7: Data Factory Tables Created

ORAtips.com ORAtips © 2006 Klee Associates, Inc.


ORAtips4On Database
Page 

January 2006 Volume II Issue 1

Figure 8: Project Folder

Step 5: Click the Run button on the


main menu. The ORA-02291 integ-
rity constraint violated error will
Figure 9: Integrity Constraint Violation
appear (Figure 9) quite a few times
(in some tables more than once)
because the loaded data in a foreign SQL> select owner, constraint_name, table_name, column_name
key-designated column does not cor- 2 from all_cons_columns
respond with data in a parent table. 3 where constraint_name like ‘%9814%’;

To work around the integrity con- OWNER CONSTRAINT_NAME TABLE_NAME COLUMN_NAME


straint violation, you can disable the ----- ------------------------------ -------------------- ------------
constraint. The query and ALTER QUEST SYS_C009814 DF_ORDERS CUSTID
TABLE statement in Figure 10 show
one method to identify and disable SQL> alter table df_orders
ORAtipsJournal

the problem constraint. 2 disable constraint sys_c009814;

Instead of analyzing each table one Table altered.


at a time, use the DBMS_STATS built- Figure 10: Disabling the Integrity Constraint Violation
in (which Oracle recommends using
for most analyze operations). If you
are using Oracle10g, you may want
to add a WHERE dropped=’NO’ to
prevent dropped tables from appear-
ing in queries on user_tables or tab
as in Figure 11.

Back in the project hierarchy or list


of tables, selecting a table in the list
will show its columns and their data
types. (Figure 12)

ORAtips.com ORAtips © 2006 Klee Associates, Inc.


ORAtips4On Database
SQL> execute dbms_stats.gather_schema_stats(‘QUEST’);
Page 

January 2006 Volume II Issue 1

uses it. If you are relying on referen-


PL/SQL procedure successfully completed.
tial integrity, your test data needs to
SQL> select table_name, num_rows
support and honor parent table-child
2 from user_tables table relationships.
3 where dropped=’NO’;
From a design standpoint, two best
TABLE_NAME NUM_ROWS practices that were violated include
-------------------- ---------- failure to index foreign key columns,
DF_TITLES 100 and failure to explicitly name three
DF_MOVIE_CUSTOMER 1100 major items (primary keys, foreign
DF_MOVIE_EMPLOYEE 900 keys, and indexes). A possible third
DF_DUMMY 1100
violation concerns not having a pri-
DF_AUTHORS_TITLES 1100
mary key on every table. Does every
DF_MOVIE_RENTAL 700
DF_PRODUCTS 100
table in a schema require a primary
DF_MOVIE_TAPE 400 key? No, but for the most part, every
DF_CUSTOMERS 1100 table should, and if not, you should
DF_AUTHORS 1100 at least have a reason. In other words,
DF_MOVIE_DISTRICT 1100 to not normalize a table should be a
DF_ORDERS 101 conscious decision, not an oversight.
DF_MOVIE_MOVIE 900
DF_ORDERDETAILS 200
DF_MOVIE_STORE 500 Darrick Addison, ASC Technolo-
gies, LLC - Darrick works as a Senior
15 rows selected.
Software Engineer/Consultant for his
Figure 11: WHERE Dropped = NO consulting company, ASC Technolo-
gies, LLC. He has been designing and
developing custom software applica-
Using the DF_MOVIE_CUSTOM- DataFactory Summary tions since 1993. He has worked on
ER table as an example (Figure 13), The key point to take away from the design and development of soft-
how does its data look? The “random this exploration of a tool such as ware ranging from database applica-
characters” option definitely produc- DataFactory is that while the tool tions, network applications (TCP/IP
es exactly that. can generate millions of rows of test client/server), GUI applications, and
or sample data, what embedded systems applications in
good is any of it if it various commercial and government
misses the boat on environments. He currently holds
referential integrity a BS degree in Computer Science
or other best prac- and is pursuing his Master’s degree
ORAtipsJournal

tices with respect in Computer Science/Telecommu-


to data modeling? nications at Johns Hopkins Univer-
If you are trying to sity. Darrick may be contacted at
tune queries for an [email protected]. ≈
application, the test
data needs to reflect Resources
Figure 12: Table Properties how the application Steve Callan, Columnist - Steve
is an Oracle DBA (OCP 8i and 9i)/
developer working in Denver. His
Oracle experience also includes
Forms and Reports, Oracle9iAS and
Oracle9iDS.

Editor’s Note: Steve Callan’s article


“How Much Is That Database In The
Figure 13: df_movie_customer Sample Window” is featured in this issue’s
CIO Corner.

ORAtips.com ORAtips © 2006 Klee Associates, Inc.


ORAtipsJournal
Page 

January 2006 Volume II Issue 1

The information on our website and in our publications is the copyrighted work of Klee Associates, Inc. and is owned by Klee Associates, Inc. NO WARRANTY: This
documentation is delivered as is, and Klee Associates, Inc. makes no warranty as to its accuracy or use. Any use of this documentation is at the risk of the user. Although
we make every good faith effort to ensure accuracy, this document may include technical or other inaccuracies or typographical errors. Klee Associates, Inc. reserves
the right to make changes without prior notice. NO AFFILIATION: Klee Associates, Inc. and this publication are not affiliated with or endorsed by Oracle Corporation.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Klee Associates, Inc. is a member of the Oracle Partner Network

This article was originally published by Klee Associates, Inc., publishers of JDEtips and SAPtips.
For training, consulting, and articles on JD Edwards or SAP, please visit our websites:
www.JDEtips.com and www.SAPtips.com.
ORAtipsJournal

ORAtips.com ORAtips © 2006 Klee Associates, Inc.

You might also like