1) You have joined a new project as an oracle DBA. Technical manager wants you to design and create a database on an existing oracle home. What are the factors that you will take into consideration while creating a database that is to offer best performance as part of CREATE DATABASE statement?
CREATE DATABASE command forms the basics upon which your database is to be built. Lots of parameters, values specified as part of this statement need to be set appropriately for optimal performance
1.1) SYSTEM tablespace should be locally managed. Make use of EXTENT MANAGEMENT LOCAL clause. Making use of this ensures that tablespaces created are locally managed. From Oracle 12c onwards by default SYSTEM tablespace is locally managed
1.2) USER specific tablespaces should be included in design. If this is not allowed leave default USERS tablespace intact. This makes sure user always access users tablespace and will not go for SYSTEM tablespace if default tablespace is not specified for the user
1.3) TEMP tablespace should be created. Temporary datafile with appropriate size should be specified. This will function as default temporary tablespace. Again SYSTEM tablespace is not used for temporary database operations temp tablespace
2) What is the real meaning of target in oracle memory tuning parameters like memory_target , pga_memory_target? Can this value be exceeded?
As the name suggests memory allocation should aim for utilization below this specified target values. This does not put hard limit on memory utilization. If there is a need to exceed the set target values, oracle instance will surpass this value
What are the major focuses of Performance tuning?
Performance tuning focuses primarily on writing efficient SQL, allocating appropriate computing resources, and analyzing wait events and contention in a system.
How does Oracle aid performance tuning?
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.
Why is performance tuning a menancing area for DBA’s?
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.
What are the approaches towards performance tuning?
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?
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?
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.
What is reactive performace tuning?
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.
Which is useful – systematic or reactive tuning?
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?
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.
What is the use of SQL over procedural languages?
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.
What is query processing?
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.
What is query optimization?
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.
What are the techniques used for query optimization?
Cost-based optimization, heuristic strategy are used for query optimization.
What are the phases of a SQL statement processing?
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.
What is Parsing?
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.
Where does the parse tree generation take place?
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.
How does a CBO generate an optimal execution plan for the SQL statement?
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.
What is query rewrite phase?
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.
What is execution plan generation phase/physical execution plan execution plan generation phase?
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.
What are the factors considered by a physical query/execution plan?
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
Which generates the query plan/what is generated by optimizer?
The optimizer generates several valid physical query plans.All the physical query plans are potential execution plans.
How does the optimizer choose the query plan/what is cost-based query optimization?/
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.
What are the factors affecting the cost of a execution plan?
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.
What happens after choosing the low-cost physical query plan?
The optimizer passes the low-cost physical query plan to the Oracle’s query execution engine.
What is a heuristic strategy?
The database uses a less systematic query optimiation technique known as the heuristic strategy./
What are unary and binary operations?
A join operation is called a binary operation, an operation like selection is called a unary operation.
What is an optimal operation processing strategy?
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.
What are the heuristic-processing strategies?
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
What is query execution?
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.
What is the crucial step in SQL statement processing?
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./
What is the job of an optimizer?
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.
What is an index?
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.
Why is an index efficient?
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.
When do we need to index tables?
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.
Why does an index traverses a table’s row faster?
Indexes prevent a full table scan,so it is inherently a faster means to traverse a table’s row
What is a baseline? Why is this important for DBA’s during performance tuning?
Performance tuning is a reactive work that starts after the system has been tested and is ready to go popularly called pre go-live (or) after go-live wherein real-time traffic, online transactions demand the DBA’s to actively look into performance issues and tune the system
Tuning is a work that demands little bit of OS knowledge in addition to database as this work can go beyond database
For a DBA to know what is the perfect functioning system a set of metrics that are established as optimal come handy. This is referred to as baselines. In case of performance issue reported DBA can check the current values against baseline to first determine if this is an issue. If they determine this to be an issue they start their work
As such performance tuning starts with baselines the set of accepted values to compare against
What are the typical peak usage periods in an oracle database environment?
This varies from system to system, area being served. time of the year like festival season etc. Typical peak hours are from
10:00am to 12:00pm
1:30pm to 3:00pm
Batch jobs, database backups using RMAN are typically run during midnight from 12:00pm to 6:00AM