Oracle Performance Tuning Interview Questions
Oracle Performance Tuning Interview Questions
1.Translate: translate function replaces a sequence of characters in a string with another set of characters.
The replacement is done single character at a time.Syntax:
translate( string1, string_to_replace, replacement_string )
Example:
translate (1tech23, 123, 456);
2.Decode: The DECODE function compares one expression to one or more other expressions and, when the
base expression is equal to a search expression, it returns the corresponding result expression; or, when no
match is found, returns the default expression when it is specified, or NA when it is not.
Syntax:
DECODE (expr , search, result [, search , result] [, default])
Example:
SELECT employee_name, decode(employee_id, 10000, tom, 10001, peter, 10002, jack Gateway) result
FROM employee;
10) What is the difference between DBFile Sequential and Scattered Reads?
Both db file sequential read and db file scattered read events signify time waited for I/O read
requests to complete. Time is reported in 100s of a second for Oracle 8i releases and below, and
1000s of a second for Oracle 9i and above. Most people confuse these events with each other as they
think of how data is read from disk. Instead they should think of how data is read into the SGA buffer
cache.
db file sequential read:
A sequential read operation reads data into contiguous memory (usually a single-block read with
p3=1, but can be multiple blocks). Single block I/Os are usually the result of using indexes. This event
is also used for rebuilding the controlfile and reading datafile headers (P2=1). In general, this event is
indicative of disk contention on index reads.
12) You see multiple fragments in the SYSTEM tablespace, what should you
check first?
Ensure that users dont have the SYSTEM tablespace as their TEMPORARY or DEFAULT tablespace assignment
by checking the DBA_USERS view.
13) What are some indications that you need to increase the
SHARED_POOL_SIZE parameter?
Poor data dictionary or library cache hit ratios, getting error ORA-04031. Another indication is steadily
decreasing performance with all other tuning parameters the same.
14) When should you increase copy latches? What parameters control copy
latches?
When you get excessive contention for the copy latches as shown by the redo copy latch hit ratio. You can
increase copy latches via the initialization parameter LOG_SIMULTANEOUS_COPIES to twice the number of
CPUs on your system.
15) If you see statistics that deal with undo what are they really talking
about?
Rollback segments and associated structures.
16) If a tablespace has a default pctincrease of zero what will this cause (in
relationship to the smon process)?
The SMON process wont automatically coalesce its free space fragments.
Infrastructure availability:
Application Tuning:
Experience showed that approximately 80% of all Oracle system performance problems are resolved
by coding optimal SQL. Also consider proper scheduling of batch tasks after peak working hours.
Memory Tuning:
Properly size your database buffers (shared pool, buffer cache, log buffer, etc) by looking at your
buffer hit ratios. Pin large objects into memory to prevent frequent reloads.
22) What tools/utilities does Oracle provide to assist with performance tuning?
Oracle provide the following tools/ utilities to assist with performance monitoring and tuning:
TKProf
UTLBSTAT.SQL and UTLESTAT.SQL Begin and end stats monitoring
Statspack
Oracle Enterprise Manager Tuning Pack
27) My query was fine last week and now it is slow. Why?
The likely cause of this is because the execution plan has changed. Generate a current explain plan of the
offending query and compare it to a previous one that was taken when the query was performing well.
Usually the previous plan is not available.
Some factors that can cause a plan to change are:
Which tables are currently analyzed? Were they previously analyzed? (ie. Was the query using RBO and now
CBO?)
Has OPTIMIZER_MODE been changed in INIT.ORA?
Has the DEGREE of parallelism been defined/changed on any table?
Have the tables been re-analyzed? Were the tables analyzed using estimate or compute? If estimate, what
percentage was used?
Have the statistics changed?
Has the INIT.ORA parameter DB_FILE_MULTIBLOCK_READ_COUNT been changed?
Has the INIT.ORA parameter SORT_AREA_SIZE been changed?
Have any other INIT.ORA parameters been changed?
What do you think the plan should be? Run the query with hints to see if this produces the required
performance.
is not being used by the CBO. If from checking the above you still feel that the query should be using an
index, try specifying an index hint. Obtain an explain plan of the query either using TKPROF with
TIMED_STATISTICS, so that one can see the CPU utilization, or with AUTOTRACE to see the statistics. Compare
this to the explain plan when not using an index.