Performance Tuning
Q.
What is Performance Tuning?
Making optimal use of system using existing resources called performance tuning.
Making optimal use of system using existing resources called performance tuning.
Q.
Types of Tunings?
1. CPU Tuning
2. Memory Tuning
3. IO Tuning
4. Application Tuning
5. Database Tuning
1. CPU Tuning
2. Memory Tuning
3. IO Tuning
4. Application Tuning
5. Database Tuning
Q.
What Mainly Database Tuning contains?
1. Hit Ratios
2. Wait Events
1. Hit Ratios
2. Wait Events
Q.
Types of hits?
Buffer hit and library hit
Buffer hit and library hit
Q.
Types of wait events?
CPU time and direct path read
CPU time and direct path read
Q.
What is an optimizer?
Optimizer is a mechanism which will make the execution plan of a SQL statement
Optimizer is a mechanism which will make the execution plan of a SQL statement
Q.
Types of Optimizers?
1. RBO(Rule Based Optimizer)
2. CBO(Cost Based Optimizer)
1. RBO(Rule Based Optimizer)
2. CBO(Cost Based Optimizer)
Q.
Which init parameter is used to make use of Optimizer?
optimizer_mode= RBO or CBO choose CBO or RBO
optimizer_mode= RBO or CBO choose CBO or RBO
Q.
Which optimizer is the best one?
CBO
CBO
Q.
What are the pre requisite to make use of Optimizer?
1. Set the optimizer mode
2. Collect the statistics of an object
1. Set the optimizer mode
2. Collect the statistics of an object
Q.
How do you collect statistics of a table?
analyze table emp compute statistics or analyze table emp estimate statistics
analyze table emp compute statistics or analyze table emp estimate statistics
Q.
What is the diff between compute and estimate?
If you use compute, The FTS(Full Table Scan) will happen, if you use estimate just 10% of the table will be read
If you use compute, The FTS(Full Table Scan) will happen, if you use estimate just 10% of the table will be read
Q.
Data Dictionary follows which optimizer mode?
RBO
RBO
Q.
How do you delete statistics of an object?
analyze table emp delete statistics
analyze table emp delete statistics
Q.
How do you collect statistics of a user/schema?
exec dbms_stats.gather_schema_stats(Scott)
exec dbms_stats.gather_schema_stats(Scott)
Q.
How do you see the statistics of a table?
select num_rows,blocks,empty_blocks from dba_tables where tab_name=’emp’
select num_rows,blocks,empty_blocks from dba_tables where tab_name=’emp’
Q.
What are chained rows?
These are rows, it spans in multiple blocks
These are rows, it spans in multiple blocks
Q.
How do you collect statistics of a user in Oracle Apps?
fnd_stats package
fnd_stats package
Q.
How do you know what sql is currently being used by the session?
by going v$sql and v$sql_area
by going v$sql and v$sql_area
Q.
What is an execution plan?
It’s a road map how sql is being executed by oracle db?
It’s a road map how sql is being executed by oracle db?
Q. How do you get the index of a table and
on which column the index is?
dba_indexes and dba_ind_columns
Q.
Which init parameter you must set to bypass parsing?
cursor_sharing=force
cursor_sharing=force
Q.
How do you know which session is running long jobs?
by going v$session_longops
by going v$session_longops
Q.
How do you flush the shared pool?
alter system flush shared_pool
alter system flush shared_pool
Q.
How do you get the info about FTS?
using v$sysstat
using v$sysstat
Q.
Where do you get the info of library cache?
v$librarycache
v$librarycache
Q.
How do you get the information of specific session?
v$mystat
v$mystat
Q.
How do you see the trace files?
using tkproof — usage: tkproof allllle.trc llkld.txt
using tkproof — usage: tkproof allllle.trc llkld.txt
Q. A tablespace has a table
with 30 extents in it. Is this bad? Why or why not?
Multiple extents in and of themselves aren’t bad. However, if you also have chained rows this can hurt performance Tuning.
Multiple extents in and of themselves aren’t bad. However, if you also have chained rows this can hurt performance Tuning.
Q.
How do you set up tablespaces during an Oracle installation?
You
should always attempt to use the Oracle Flexible Architecture standard or
another partitioning scheme to ensure proper separation of SYSTEM, ROLLBACK,
REDO LOG, DATA, TEMPORARY and INDEX segments.
Q. You see multiple
fragments in the SYSTEM tablespace, what should you check first?
Ensure that users don’t have the SYSTEM tablespace as their TEMPORARY or DEFAULT tablespace assignment by checking the DBA_USERS view.
Ensure that users don’t have the SYSTEM tablespace as their TEMPORARY or DEFAULT tablespace assignment by checking the DBA_USERS view.
Q. 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.
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.
Q.
What is the general guideline for sizing db_block_size and db_multi_block_read
for an application that does many full table scans?
Oracle almost always reads in 64k chunks. The two should
have a product equal to 64 or a multiple of 64.
Q.
What is the fastest query method for a table?
Fetch by rowid
Fetch by rowid
Q.
Explain the use of TKPROF? What initialization parameter should be turned on to
get full TKPROF output?
The tkproof tool is a tuning tool used to determine CPU and execution times for SQL statements. You use it by first setting timed_statistics to true in the initialization file and then turning on tracing for either the entire database via the sql_trace parameter or for the session using the ALTER SESSION command. Once the trace file is generated you run the tkprof tool against the trace file and then look at the output from the tkprof tool. This can also be used to generate explain plan output.
Q.
When looking at v$sysstat you see that sorts (disk) is high. Is this bad or
good? If bad, how do you correct it?
If
you get excessive disk sorts this is bad. This indicates you need to tune the
sort area parameters in the initialization files. The major sort is parameter
is the SORT_AREA_SIZE parameter.
Q.
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.
Q. Where
can you get a list of all initialization parameters for your instance? How
about an indication if they are default settings or have been changed?
You can look in the init.ora file for an indication of manually set parameters. For all parameters, their value and whether the current value is the default value, look in the v$parameter view.
Q. Describe hit ratio as it
pertains to the database buffers. What is the difference between instantaneous
and cumulative hit ratio; which should be used for tuning?
Hit ratio is a measure of how many times the database was able to read a value from the buffers verses how many times it had to re-read a data value from the disks. A value greater than 80-90% is good, less could indicate problems. If you take the ratio of existing parameters this will be a cumulative value since the database started. If you do a comparison between pairs of readings based on some arbitrary time span, this is the instantaneous ratio for that time span. An instantaneous reading gives more valuable data since it will tell you what your instance is doing for the time it was generated over.
Hit ratio is a measure of how many times the database was able to read a value from the buffers verses how many times it had to re-read a data value from the disks. A value greater than 80-90% is good, less could indicate problems. If you take the ratio of existing parameters this will be a cumulative value since the database started. If you do a comparison between pairs of readings based on some arbitrary time span, this is the instantaneous ratio for that time span. An instantaneous reading gives more valuable data since it will tell you what your instance is doing for the time it was generated over.
Q. Discuss row chaining,
how does it happen? How can you reduce it? How do you correct it?
Row chaining occurs when a VARCHAR2 value is updated and the length of the new value is longer than the old value and won’t fit in the remaining block space. This results in the row chaining to another block. It can be reduced by setting the storage parameters on the table to appropriate values. It can be corrected by export and import of the effected table.
Row chaining occurs when a VARCHAR2 value is updated and the length of the new value is longer than the old value and won’t fit in the remaining block space. This results in the row chaining to another block. It can be reduced by setting the storage parameters on the table to appropriate values. It can be corrected by export and import of the effected table.
Q. When looking at the estat events report you see that
you are getting busy buffer waits. Is this bad? How can you find what is
causing it?
Buffer busy waits may indicate contention in redo, rollback or data blocks. You
need to check the v$waitstat view to see what areas are causing the problem.
The value of the “count” column tells where the problem is, the “class” column
tells you with what. UNDO is rollback segments, DATA is data base buffers.
Q. If you see contention
for library caches how can you fix it?
Increase the size of the shared pool.
Increase the size of the shared pool.
Q. If you see statistics
that deal with “undo” what are they really talking about?
Rollback segments and associated structures.
Rollback segments and associated structures.
Q.
If a tablespace has a default pct increase of zero what will this cause
(in relationship to the smon process)?
The SMON process won’t automatically coalesce its free space fragments.
Q. If a tablespace shows excessive fragmentation what are some methods to defragment the tablespace? (7.1,7.2 and 7.3 only)
In Oracle 7.0 to 7.2 The use of the ‘alter session set events ‘immediate trace name coalesce level ts#’;’ command is the easiest way to defragment contiguous free space fragmentation. The ts# parameter corresponds to the ts# value found in the ts$ SYS table. In version 7.3 the ‘alter tablespace coalesce;’ is best. If free space isn’t contiguous then export, drop and import of the tablespace contents may be the only way to reclaim non-contiguous free space.
Q.
How can you tell if a tablespace has excessive fragmentation?
If a select against the dba_free_space table shows that the count of a tablespaces extents is greater than the count of its data files, then it is fragmented.
Q.
You see the following on a status report:
redo log space requests 23
redo log space wait time 0
Is this something to worry about? What if redo log space wait time is high? How can you fix this?
Since wait time is zero, no. If wait time was high it might indicate a need for more or larger redo logs.
redo log space requests 23
redo log space wait time 0
Is this something to worry about? What if redo log space wait time is high? How can you fix this?
Since wait time is zero, no. If wait time was high it might indicate a need for more or larger redo logs.
Q. What can cause a high value for
recursive calls? How can this be fixed?
A high value for recursive calls is cause by improper cursor usage, excessive dynamic space management actions, and or excessive statement re-parses. You need to determine the cause and correct it By either relinking applications to hold cursors, use proper space management techniques (proper storage and sizing) or ensure repeat queries are placed in packages for proper reuse.
A high value for recursive calls is cause by improper cursor usage, excessive dynamic space management actions, and or excessive statement re-parses. You need to determine the cause and correct it By either relinking applications to hold cursors, use proper space management techniques (proper storage and sizing) or ensure repeat queries are placed in packages for proper reuse.
Q.
If you see a pin hit ratio of less than 0.8 in the estat library cache report
is this a problem? If so, how do you fix it?
This indicates that the shared pool may be too small. Increase the shared pool size.
Q. If you see the value for
reloads is high in the estat library cache report is this a matter for concern?
Yes, you should strive for zero reloads if possible. If you see excessive reloads then increase the size of the shared pool.
Yes, you should strive for zero reloads if possible. If you see excessive reloads then increase the size of the shared pool.
Q. You look at the
dba_rollback_segs view and see that there is many shrinks and they are of
relatively small size, is this a problem? How can it be fixed if it is a
problem?
Many small shrinks indicate a need to increase the size
of the rollback segment extents. Ideally
you should have no shrinks or a small number of large shrinks. To fix this just
increase the size of the extents and adjust optimal accordingly.
Q.
You look at the dba_rollback_segs view and see that you have many wraps is this
a problem?
Many wraps indicate that your extent size for your rollback segments are probably too small. Increase the size of your extents to reduce the number of wraps. You can look at the average transaction size in the same view to get the information on transaction size.
Q. In a system with an
average of 40 concurrent users you get the following from a query on rollback
extents:
ROLLBACK CUR EXTENTS
——————— ————————–
R01 11
R02 8
R03 12
R04 9
SYSTEM 4
You have room for each to grow by 20 more extents each. Is there a problem? Should you take any action?
No there is not a problem. You have 40 extents showing and an average of 40 concurrent users. Since there is plenty of room to grow no action is needed.
ROLLBACK CUR EXTENTS
——————— ————————–
R01 11
R02 8
R03 12
R04 9
SYSTEM 4
You have room for each to grow by 20 more extents each. Is there a problem? Should you take any action?
No there is not a problem. You have 40 extents showing and an average of 40 concurrent users. Since there is plenty of room to grow no action is needed.
Q. You see multiple extents
in the temporary tablespace. Is this a problem?
As long as they are all the same size this isn’t a problem. In fact, it can even improve performance since Oracle won’t have to create a new extent when a user needs one.
As long as they are all the same size this isn’t a problem. In fact, it can even improve performance since Oracle won’t have to create a new extent when a user needs one.
Q3) Explain IO Tuning
Answer: Database files must be sized correctly and located on the
right place to afford supreme disk subsystem quantity. Also, look out for missing indexes, regular disk
sorts, row chaining, data fragmentation, complete table scans, and so on.
Q4) Explain Memory Tuning
Answer: Properly sizing the database buffers such as
buffer cache, log buffer, shared pool, buffer cache by analyzing the ratios of buffer hit. Large objects are pinned into
memory to avoid recurrent refills.
Q5) Explain Application Tuning
Answer: As per various experiences, it is well displaying
that about 80 percent of Oracle system performance
issues are fixed using optimal SQL code. Batch tasks must be properly scheduled
on time.
Q6) Explain proactive tuning
Answer: Application engineers will be able to determine
which grouping of oracle features and
system resources will best fulfill the requirements at the time of development
and planning. This process is called proactive tuning.
Q7) Explain reactive tuning
Answer: Bottom-up method is employed to discover and
resolve the blockages. This process is called reactive tuning. The goal of
reactive tuning is to run Oracle quicker.
Q8) Define optimizer
Answer: Optimizer, a mechanism that makes the SQL
statement execution plan
Q9) What are the types of
Optimizer?
Answer: Cost Based Optimizer (CBO) and Rule-Based
Optimizer (RBO)
Q10) What is Rule-Based Optimizer (RBO)?
Answer: When a server does not have internal statistics
with respect to the objects influenced by the statement, here RBO plays its
role.
Q11) What is Cost Based Optimizer (CBO)?
Answer: If internal statistics are available, CBO method
is employed over there. CBO performs various checks on all the possible execution plans and picks one that has
the bottommost charge depending on
the system resources.
Q12) To use Optimizer, what are the pre-requisites?
Answer: Initially set the optimizer mode and collect the
object statistics
Q13) How to collect table
statistics?
Answer: Examine the table emp estimate statistics (or) the
table emp compute statistics
Q14) What is the
abbreviation of FTS?
Answer: Abbreviation of FTS is “Full Table Scan”
Q15) Provide the difference between the estimate and compute?
Answer: FTS happens if using compute. Only 10% of the
table gets read if using the estimate.
Q16) Name the best optimizer
Answer: Best optimizer is Cost Based Optimizer (CBO)
Q17) Name the optimizer which is followed by Data Dictionary
Answer: Rule-Based Optimizer (RBO) is the optimizer
followed by Data Dictionary
Q18) Define Chain Rows
Answer: Chain rows are the rows that span in various
blocks
Q19) Define Execution Plan
Answer: Execution plan is a road map giving details on how oracle DB executes SQL
Q20) Mention the count of
Hits
Answer: There are two (2) hits
Q21) Provide the hits of Oracle Performance Tuning
Answer: Two hits of Oracle Performance Tuning are Library hit and Buffer hit
Q22) Provide the Wait Events types
Answer: Direct path read, and CPU time is the Wait Event
types
Q23) Provide the quickest
query method for a table?
Answer: The quickest query method for a table is to fetch
by rowid
Q24) How will you fix if
there is a contention for Library Caches?
Answer: If there is a contention for library caches, just
increase the shared pool size
Q29) Mention the cause of a high value for
recursive calls?
Answer: Extreme dynamic space administration activities,
unnecessary statement re-parses, and inappropriate cursor practice can lead to
a high value for recursive calls.
Q30) How to fix when seeing
a high value for recursive calls?
Answer: Initially it is important to determine the causes
and correct it with any of the following activities:
·
Make use of appropriate space management procedures
·
Relinking applications to grip the cursors
·
Confirm the repeated questions are in packages for proper reuse.
Q36) What is Intersect?
Answer: ‘Intersect’ permits to combine the outcomes of
two or more select queries. If you can see a record available in a query and
not visible on the other, those records get removed from Intersect results.
Q37) What is Union?
Answer: ‘Union’ operator is for combining the outcomes
which are a set of two or more Select statements. Both the select statement of
that table should have a similar count of columns along with the same data
types as the duplicates are eliminated.
Q39) List out the tools
provided by Oracle to help in performance tuning
Answer: Below is the tools provided by Oracle to help in
performance tuning:
·
Statspack
·
TKProf
·
Oracle Enterprise Manager
·
SQL and UTLESTAT.SQL
Q41) In the SYSTEM
tablespace if you find multiple fragments, what should be checked first?
Answer: Make sure that users are not having the System
tablespace as their default or temporary tablespace assignment by inspecting
the view of DBA_USERS.
Q42) Provide the difference
between latches and locks?
Answer: Maintaining read steadiness on instance memory
structures is called latches. Maintaining read steadiness on tables is called
locks.
Q43) When will you say a
database object is invalid?
Answer: A database object is said to be invalid when the
fundamental base objects are modified.
Q44) Mention a query to make
use of the entire full table scan though the table has an index
Answer: Use the query “hint” to use the entire full table
scan
Q45) Provide the regularity of performing database re-organization?
Answer: Database re-organization is not required if ASSM
is used. If ASSM is not used, good to perform the re-organization once in every
6 months.
Q46) Why indexes are
becoming unusable while moving a table?
Answer: When a table is moved, the row ids are changed,
and the index is dependent on that row id. Hence, indexes become unusable.
Q47) What is the purpose of
partitioning?
Answer: Partitioning helps in hunting data simply as the
data are stockpiled in numerous partitions.
Q48) What is the reason to
opt composite partitioning?
Answer: If there is a large table and faster access is
required, composite portioning helps much.
Q49) Is it possible to move
a table to the same tablespace?
Answer: Yes, it is possible to move a table to the same
tablespace if we have adequate free space
Q50) Define ADDM in 10g
Answer: ADMM (Automatic Database Diagnostic Monitor) is a
utility helpful in affording few endorsements depending on the statistics
gathered for every 1 hour.
Why is performance tuning a menacing area for DBA’s?
Ans: Like many other features of Oracle like exp/imp,backup recovery this field can’t be automated. This is one area that requires a lot of detective work on the part of application programmers and DBA’s to see w some process is running slower than expected, why can’t we scale applications to a larger number of users without problems like performance degradation etc. This is a area where our technical knowledge must be used along with constant experimentation and observation.
Ans: Like many other features of Oracle like exp/imp,backup recovery this field can’t be automated. This is one area that requires a lot of detective work on the part of application programmers and DBA’s to see w some process is running slower than expected, why can’t we scale applications to a larger number of users without problems like performance degradation etc. This is a area where our technical knowledge must be used along with constant experimentation and observation.
What are the approaches towards performance tuning?
Ans: We can follow either a systematic approach or a reactive approach for performance tuning.
What is a systematic approach to performance tuning?
It is mandatory to design the database properly at initial stages to avoid potential problems. It is mandatory to know the nature of application that a database is going to support. With a clear idea on the application’s nature database can be optimally created by allocating appropriate resources to avoid problems when the application is moved to production. Most production moves cause problem because of the scalability problems with the applications. So, oracle recommends to tune database at inception stage. this is systematic approach to performance tuning.
Ans: We can follow either a systematic approach or a reactive approach for performance tuning.
What is a systematic approach to performance tuning?
It is mandatory to design the database properly at initial stages to avoid potential problems. It is mandatory to know the nature of application that a database is going to support. With a clear idea on the application’s nature database can be optimally created by allocating appropriate resources to avoid problems when the application is moved to production. Most production moves cause problem because of the scalability problems with the applications. So, oracle recommends to tune database at inception stage. this is systematic approach to performance tuning.
What are the Oracle’s suggestions towards systematic tuning?
Ans: Oracle suggests a specific design approach with the following steps. This is a top down approach:
1) Design the application correctly
2) Tune the application SQL code
3) Tune memory
4) Tune I/O
5) Tune contention and other issues
Ans: Oracle suggests a specific design approach with the following steps. This is a top down approach:
1) Design the application correctly
2) Tune the application SQL code
3) Tune memory
4) Tune I/O
5) Tune contention and other issues
What are the effects of
poor database design?
Ans: A poor database design results in poor application performance. We must tune the application code and some database resources such as memory,CPU,I/O owing to performance degradation. An application performs well in development and testing. Will there be any performance problem when it is moved to production?
Production moves may cause problems due to scalability. We can’t simulate the original load in test and development. So, problems may crop up at times as the application may be performing poor due to scalability problems.
Ans: A poor database design results in poor application performance. We must tune the application code and some database resources such as memory,CPU,I/O owing to performance degradation. An application performs well in development and testing. Will there be any performance problem when it is moved to production?
Production moves may cause problems due to scalability. We can’t simulate the original load in test and development. So, problems may crop up at times as the application may be performing poor due to scalability problems.
Which is useful – systematic or reactive tuning?
Ans: The performance tuning steps to improve the performance of a database depends on the stage at which we get the input and on the nature of the application. DBA’s can assist the developers to write optimal code that is scalable based on systematic approach. Mostly the real-life problems that are encountered after production moves have to be solved by reactive performance tuning.
Ans: The performance tuning steps to improve the performance of a database depends on the stage at which we get the input and on the nature of the application. DBA’s can assist the developers to write optimal code that is scalable based on systematic approach. Mostly the real-life problems that are encountered after production moves have to be solved by reactive performance tuning.
We have an application
whose code can’t be changed. Can we improve its performance?
Ans: We can improve the application performance without changing base SQL code by optimizing the SQL performance. Oracle has come up with SQL Advisor tool that helps SQL performance. We can make use of SQL Advisor tools’ SQL Profiles to improve performance, though we can’t touch the underlying SQL.
Ans: We can improve the application performance without changing base SQL code by optimizing the SQL performance. Oracle has come up with SQL Advisor tool that helps SQL performance. We can make use of SQL Advisor tools’ SQL Profiles to improve performance, though we can’t touch the underlying SQL.
Q.What is query processing?
Ans: When a user starts a data retrieval operation, the user’s SQL statement goes through several sequential steps that together constitute query processing. Query processing is the transformation of the SQL statement into efficient execution plan to return the requested data from the database.
Ans: When a user starts a data retrieval operation, the user’s SQL statement goes through several sequential steps that together constitute query processing. Query processing is the transformation of the SQL statement into efficient execution plan to return the requested data from the database.
Q.What is query
optimization?
Ans: Query optimization is the process of choosing the most efficient execution plan. The goal is to achieve the result with least cost in terms of resource usage. Resources include I/O and CPU usage on the server where the database is running. This is a means to reduce the execution times of the query, which is the sum of the execution times of the all component operations of the query.
Ans: Query optimization is the process of choosing the most efficient execution plan. The goal is to achieve the result with least cost in terms of resource usage. Resources include I/O and CPU usage on the server where the database is running. This is a means to reduce the execution times of the query, which is the sum of the execution times of the all component operations of the query.
Q.What are the phases of a SQL statement processing?
Ans: SQL statement goes through the parsing, optimizing, and execution stages. If the SQL statement is a query(SELECT),data must be retrieved so there’s an additional fetch stage before
the SQL processing is complete.
Ans: SQL statement goes through the parsing, optimizing, and execution stages. If the SQL statement is a query(SELECT),data must be retrieved so there’s an additional fetch stage before
the SQL processing is complete.
Q.What is Parsing?
Ans: Parsing primarily consists of checking the syntax and semantics of the SQL statements. The product of the parse stage of query compilation is the creation of a parse tree, which represents the query structure. The parse tree is then sent to the logical query plan generation stage.
Ans: Parsing primarily consists of checking the syntax and semantics of the SQL statements. The product of the parse stage of query compilation is the creation of a parse tree, which represents the query structure. The parse tree is then sent to the logical query plan generation stage.
What is Optimization/what happens during optimization
phase?
During the optimization phase, Oracle uses its optimizer(CBO(cost-based optimizer)) to choose the best access method for retrieving data for the tables and indexes referred to in the query.
During the optimization phase, Oracle uses its optimizer(CBO(cost-based optimizer)) to choose the best access method for retrieving data for the tables and indexes referred to in the query.
Q.How does a CBO generate
an optimal execution plan for the SQL statement?
Ans: Using the statistics we provide and the hints specified in the SQL queries, the CBO produces an optimal execution plan for the SQL statement.
What are the parts of an optimizer phase?
An optimizer phase can be divided into two distinct parts: the query rewrite phase and the physical execution plan generation phase.
Ans: Using the statistics we provide and the hints specified in the SQL queries, the CBO produces an optimal execution plan for the SQL statement.
What are the parts of an optimizer phase?
An optimizer phase can be divided into two distinct parts: the query rewrite phase and the physical execution plan generation phase.
Q.What is query rewrite phase?
Ans: In this phase ,the parse tree is converted into an abstract logical query plan. This is an initial pass at an actual query plan, and it contains only a general algebraic reformulation of the initial query. The various nodes and branches of the parse tree are replaced by operators of relational algebra.
Ans: In this phase ,the parse tree is converted into an abstract logical query plan. This is an initial pass at an actual query plan, and it contains only a general algebraic reformulation of the initial query. The various nodes and branches of the parse tree are replaced by operators of relational algebra.
Q.What are the factors considered by a physical query/execution
plan?
Ans: Following factors are considered by a physical query or an execution plan:
1) The various operations(eg:joins) to be performed during the query
2) The order in which the operations are performed
3) The algorithm to be used for performing each operation
4) The best way to retrieve data from disk or memory
5) The best way to pass data from one operation to another during the query
Ans: Following factors are considered by a physical query or an execution plan:
1) The various operations(eg:joins) to be performed during the query
2) The order in which the operations are performed
3) The algorithm to be used for performing each operation
4) The best way to retrieve data from disk or memory
5) The best way to pass data from one operation to another during the query
Q.Which generates the query plan/what is generated by optimizer?
Ans: The optimizer generates several valid physical query plans. All the physical query plans are potential execution plans.
Ans: The optimizer generates several valid physical query plans. All the physical query plans are potential execution plans.
Q.How does the optimizer
choose the query plan/what is cost-based query optimization?
Ans: The optimizer generates several physical query plans that are potential execution plans. The optimizer then chooses among them by estimating the cost of each possible physical plan based on the table and index statistics available to it and selecting the plan with the lowest estimated cost. This evaluation of the possible physical query plans is called cost-based query optimization.
Ans: The optimizer generates several physical query plans that are potential execution plans. The optimizer then chooses among them by estimating the cost of each possible physical plan based on the table and index statistics available to it and selecting the plan with the lowest estimated cost. This evaluation of the possible physical query plans is called cost-based query optimization.
Q.What are the factors
affecting the cost of a execution plan?
Ans: The cost of executing a plan is directly proportional to the amount of resources such as I/O,memory and CPU necessary to execute the proposed plan.
Ans: The cost of executing a plan is directly proportional to the amount of resources such as I/O,memory and CPU necessary to execute the proposed plan.
Q.What happens after
choosing the low-cost physical query plan?
Ans: The optimizer passes the low-cost physical query plan to the Oracle’s query execution engine.
Ans: The optimizer passes the low-cost physical query plan to the Oracle’s query execution engine.
Q.What is a heuristic strategy?
Ans: The database uses a less systematic query optimization technique known as the heuristic strategy.
Ans: The database uses a less systematic query optimization technique known as the heuristic strategy.
Q.What are unary and binary operations?
Ans: A join operation is called a binary operation, an operation like selection is called a unary operation.
Ans: A join operation is called a binary operation, an operation like selection is called a unary operation.
Q.What is an optimal operation processing strategy?
Ans: In general an optimal strategy is to perform unary operations first so the more complex and time-consuming binary operations use smaller operands. Performing as many of the possible unary operations first reduces the row sources of the join operations.
Ans: In general an optimal strategy is to perform unary operations first so the more complex and time-consuming binary operations use smaller operands. Performing as many of the possible unary operations first reduces the row sources of the join operations.
Q.What are the heuristic-processing strategies?
Ans: 1) Perform selection operation early so that we can eliminate a majority of the candidate rows early in the operation. If we leave most rows in until the end, we’re going to do needless comparisons with the rows we’re going to get rid of later
2) Perform projection operations early so that we limit the number of columns we have to deal with
3) If we need to perform consecutive join operation,perform the operations that produce the smaller join first
4) Compute common expressions once and save the results
Ans: 1) Perform selection operation early so that we can eliminate a majority of the candidate rows early in the operation. If we leave most rows in until the end, we’re going to do needless comparisons with the rows we’re going to get rid of later
2) Perform projection operations early so that we limit the number of columns we have to deal with
3) If we need to perform consecutive join operation,perform the operations that produce the smaller join first
4) Compute common expressions once and save the results
Q.What is query execution?
Ans: During the final stage of a query processing, the optimized query(the physical query plan that has been selected) is executed. If it’s a SELECT statement, the rows are returned to the user. If it’s an INSERT,UPDATE or DELETE statement ,the rows are modified. The SQL execution engine takes the execution plan provided by the optimization phase and executes it.
Ans: During the final stage of a query processing, the optimized query(the physical query plan that has been selected) is executed. If it’s a SELECT statement, the rows are returned to the user. If it’s an INSERT,UPDATE or DELETE statement ,the rows are modified. The SQL execution engine takes the execution plan provided by the optimization phase and executes it.
Q.What is the job of an
optimizer?
Ans: The job of an optimizer is to find the optimal/best plan to execute our DML statements such as SELECT,INSERT,UPDATE and DELETE. Oracle uses CBO to help determine efficient methods to execute queries.
Ans: The job of an optimizer is to find the optimal/best plan to execute our DML statements such as SELECT,INSERT,UPDATE and DELETE. Oracle uses CBO to help determine efficient methods to execute queries.
Q.What is an index?
Ans: An index is a data structure that takes the value of one or more columns of a table(the key) and returns all rows/requested-columns in a row quickly.
Ans: An index is a data structure that takes the value of one or more columns of a table(the key) and returns all rows/requested-columns in a row quickly.
Q.When do we need to index
tables?
Ans: We need to index tables only when the queries will be selecting a small portion of the table. If our query is retrieving rows that are greater than 10 or 15 percent of the total rows in the table, we may not need an index.
Ans: We need to index tables only when the queries will be selecting a small portion of the table. If our query is retrieving rows that are greater than 10 or 15 percent of the total rows in the table, we may not need an index.
Q.Why does an index
traverses a table’s row faster?
Ans: Indexes prevent a full table scan, so it is inherently a faster means to traverse a table’s row
Ans: Indexes prevent a full table scan, so it is inherently a faster means to traverse a table’s row
Q.What are some indications that you need to increase the
SHARED_POOL_SIZE parameter?
Ans: 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.
Ans: 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.
Q #1) Why do we use the
materialized view instead of a table or views?
Answer: Materialized
view is a database object that holds
query results. If materialized views are used instead of tables or
views in complex query executions, performance gets enhanced as re-execution is
not required for repeated queries.
Q #2) How is the Clustered Index different from the Non-Clustered
Index?
Answer: An index
is a schema object, which can search the data efficiently within the table.
Indexes can be clustered or non-clustered. Differences include:
- In
a clustered index, table records are sorted physically and stored in a
particular order. Hence, a table can have a single clustered index only.
While in a non-clustered index, logical sorting happens which does not
match the physical order of the records.
- Leaf
node of a clustered index holds the data pages while the non-clustered
index holds the index rows.
Comments
Post a Comment