Oracle Performance Tuning Interview Questions

Oracle Performance Tuning Interview Questions and Answers Q.What are the major focuses of Performance tuning? Ans: Performance tuning focuses primarily on writing efficient SQL, allocating appropriate computing resources, and analyzing wait events and contention in a system. Q.How does Oracle aid performance tuning? Ans: Oracle provides several options to aid performance tuning, such as partitoning lar tables, using materialized views, storing plan outlines, using tools like Automatic Optimizer statistics collection feature, ckages like DBMS_STATS, SQL Tuning Advisor to tune SQL statements,etc. Q.Why is performance tuning a menacing area for DBA’s? Ans: Like many other features of Oracle like exp/imp,backu 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. Q.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. Q.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 Q.What are the effects of poor database design? Ans: A poor database design results in poor application performance. We have to tune the application code and some database resources such as memory,CPU,I/O owing to performance degradation. An applications 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. Q.What is reactive performace tuning? Ans: Performance tuning is an iterative process. We as a DBA may have to tune applications which is designed and implemented in production.The performance tuning at htis stage is referred to as reactive performance tuning. Q.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. Q.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. Q.What is the use of SQL over procedural languages? Ans: SQL isn’t a procedural language in which we have to specify the steps to be followed to achieve the statement goal.We don’t have to specify how to accomplish a task(say data retrival) using SQL,rather we can specify as to what needs to be done. 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. 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 dat/abase 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 techniques used for query optimization? Ans: Cost-based optimization, heuristic strategy are used for query optimization. Q.What are the phases of a SQL statement processing? Ans: An user’s SQL statement goes through the parsing,optimizing, and execution stages.If the SQL statement is a query(SELECT),data has to be retrived 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 end 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. Mention the steps in the creation of a parse tree:- 1) The SQL statement is decomposed into relational algebra query that ‘s analyzed to see whether it’s syntactically correct. 2) The query then undergoes semantic checking. 3) The data dictionary is consulted to ensure that the tables and the individual columns that are referenced in the query do exist,as well as all the object privileges. 4) The column types are checked to ensure that the data matches the column definition. 5) The statement is normalized so that it can be processed more efficiently 6) The query is rejected if it is incorrectly formulated 7) Once the parse tree passes all the syntactic and semantic checks,it is considered a valid parse tree,and it’s sent to the logical query plan generation stage. Q.Where does the parse tree generation take place? Ans: The parse tree generation takes place in the library cahce portion of the SGA(system global Area)./ 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 retriving 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. 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. Q.What is execution plan generation phase/physical execution plan execution plan generation phase? Ans: During this phase,Oracle transforms the logical query plan into a physical query plan. The optimizer may be faced with a choice of several algorithms to solve a query. It needs to choose the most efficient algorithm to answer a query,and it needs to determine the most efficient way to implement the operations.The optimizer determines the order in which it will perform the steps. 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 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. 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. 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. 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. Q.What is a heuristic strategy? Ans: The database uses a less systematic query optimiation 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. 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. 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 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. Q.What is the crucial step in SQL statement processing? Ans: Of the three steps involved in the SQL statement processing, the optimization process is the crucial one because it determines the all important question of how fast our data will be retrived./ 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. 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. Q.Why is an index efficient? Ans: The efficiency of an index comes from the fact that it lets us find necessary rows without having to scan all the rows of a table.They need a fewer disk I/O’s than if we had to scan the table and hence are efficient. 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 retriving 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 Q.A tablespace has a table with 30 extents in it. Is this bad? Why or why not? Ans: Multiple extents in and of themselves aren’t bad. However if you also have chained rows this can hurt performance. Q.How do you set up tablespaces during an Oracle installation? Ans: 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? Ans: 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? 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.What is the general guideline for sizing db_block_size and db_multi_block_read for an application that does many full table scans? Ans: 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? Ans: Fetch by rowid Q.Explain the use of TKPROF? What initialization parameter should be turned on to get full TKPROF output? Ans: The tkprof 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? Ans: 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 are parameter is the SORT_AREA_SIZE parameter. Q.When should you increase copy latches? What parameters control copy latches? Ans: 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? Ans: You can look in the init.ora file for an indication of manually set parameters. For all parameters, their value ad whether or not 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 total hit ratio; which should be used for tuning? Ans: 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 ***ulative 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. Generally speaking 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? Ans: 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? Ans: 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? Ans: Increase the size of the shared pool. Q.If you see statistics that deal with “undo” what are they really talking about? Ans: Rollback segments and associated structures. Q.If a tablespace has a default pctincrease of zero what will this cause (in relationship to the smon process)? Ans: 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) Ans: 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? Ans: 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? Ans: 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? Ans: 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? Ans: 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? Ans: 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 a large number of shrinks and they are of relatively small size, is this a problem? How can it be fixed if it is a problem? Ans: A large number of small shrinks indicates 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 a large number of wraps is this a problem? Ans: A large number of wraps indicates 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: Ans: ROLLBACK CUR EXTENTS ——————— ————————– R01 11 R02 8 R03 12 R04 9 SYSTEM 4 Q.You have room for each to grow by 20 more extents each. Is there a problem? Should you take any action? Ans: 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? Ans: 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. contact for more on Oracle Performance Tuning Online Training oracle performance tuning interview questions

Oracle Performance Tuning interview questions Tags

oracle performance tuning interview questions and answers,oracle performance tuning online training, oracle performance tuning interview questions, oracle performance tuning training online, oracle performance tuning training, oracle performance tuning training institute, latest oracle performance tuning interview questions, best oracle performance tuning interview questions 2019, top 100 oracle performance tuning interview questions,sample oracle performance tuning interview questions,oracle performance tuning interview questions technical, best oracle performance tuning interview tips, best oracle performance tuning interview basics, oracle performance tuning Interview techniques, oracle performance tuning Interview Tips. For  online training videos