how select, Insert and update are perform IN ORACLE
In every database operation s flow is same. May be the
memory components or background processers are different but work is same.
Intensively oracle client passed a request to fullfil his requirement. In a
way, oracle client request has accept and proceed forward to get some results.
As per my knowledge it's not a magical show to everything like a mercy. Oracle
internally passed out many issues to gain the end-user satisfaction. In this
article I want to show something and how database doing all the DML,DDL
operation to Meetup the end user resources. Mainly database operation are like
starts with SELECT, INSERT, UPDATE OR DELETE.

1) how the select operator providing the exact results?
Oracle Client gives a request to oracle server. Server wil
accept the request, it will produce the result. Before going to produce the
results it has to fallow some steps.
- after accepting the request server will invoke the oracle instance by creating a session. The request must contain a statement ID. We need to provide some proof to manager. When he asks abut reasons to handshake with database? Who did this? What they did?
- instance is collection of memory components and background process. Some body doing something means something is happening to my database. Shared pool will provide a hash value. It is just like a pointer for statement id.
2) the recognized statement will enter into DB components.
Here we need to know whether given statement is properly mentioned or not. If
it a correct statement, whether it has proper privileges or not. We need check
on this step. This is called as parsing. Parsing is tree representation. It
will be top-down approach or bottom-top approach. The main intention for
parsing I.e the statement will be
decided into words. It will represented in tree model to check the synthatical
checking and semenatical check.
- synthetical checking = it will check for synax of a statement weather it is correctly represented or not. If the client is an intelligent client like SQL*plus. The synthax checking will be done at client side, otherwise it will be done at SGA. Unfortunatlly, Syntax of statement is not in a proper way. Server will through an error to end-user. If it is correct it will ready for next step.
- semenatical check- here we need to know about the statement objects are presented in the database or not. If object is there, then check whether objects contains the perfect privileges are there are not to the client who gives the request for accessing with Database objects.
3) everything is ok with parsing. Optimizer will invoke and
check the objects are presented in the ddc or not. If it is found in ddc. Based
on the execution plan and it's plan_hash_value will refer the best path to
execute the statement. Here we have two kinds of parsings are done.
- hard parsing: first time execution of the statement. It will not represented in buffer cache as well as doesn't contain any execution plans. The data has to fetch from datafiles, it means we need to touch the physical files. It is so hard and need dug the physical components i.e it is called as hard parsing
- soft parsing: second time execution of a statement. Statement related information or contents are represented in buffer caches. So we no need to interact with physical file. Based on the execution plan. Optimizer will gives the best plan to retrieve the data. It's completely taken care by optimizer, based on statistics it will provide his best. How optimizer will collect the statistics?
- Here we have two kinds of approaches are there.. those are
- Rule based optimizer: In this approach, optimizer will choose only pre determined set of rules. It means based on , what kind of indexes or hash joins are builted on the statements. It will consider,have look on the rules then calculate the cost(CPU utilization). It is no one used in the market.
- cost based optimizer: here we can consider only cost of the statement by collecting statictics. You can read my execution plan artical for better understanding purpose. We can know , what kind of optimizer we are using with the help of optimizer_mode=rule/cost.
4) after collecting the cost of a statement, optimizer will
decides Which is the best execution plan. the plan will be stored in library
cache.
5) by using the exectlion plan, data will be fetched into
DBBC. Database objects are represented in DDC
6) data will transformed to client to show the result
-------------------------------------------------------------------------------------------------------------------------
Insert operation
1) provide the statement of and hash values
2) parsing wil be done.
3) optimizer will invoke to give the execution plan.
4) based on the execution we will able to insert into database objects.
5) stores the plan
6) based on the pctfree,pctused and freelist availability.
Data will be inserted into specific objects when the user gives commit.
Otherwise rollbacks.
-----------------------------------------------------------------------------------------------------------------------
Updates
1) Same steps upto optimizer and it will store the execution
plan.
2) going to update values, old values are kept into undo and
new values are inserted into datafiles without SCN. When the user gives an
commit , SCN will attached to datafiles as well as control file.
If he will give rollback. Based on the undo retention policy
the updation will be canceled. Old values becomes reinserted and new values are
flushed out.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home