Translate

ORACLE SQL Query Order of Operations

How ORACLE process the SQL Query? What is SQL Query Logical Processing Order?

Consider below Query clauses and understand how they get processed when executed in a form of a SQL Query:

FROM
JOINs
GROUP by
HAVING
WHERE
SELECT
ORDER BY



So, calculated SELECT columns or alias will not be available in the WHERE clause, but they will be available in the ORDER BY clause. Because the SELECT clause executed right before hand, everything from the SELECT should be available at the time of ORDER BY execution.

Also, SELECT columns are not referenceable  in the WHERE clause. If you create a column in the SELECT directive. It will not be available in the WHERE clause because the SELECT clause has not even been executed at the time the WHERE clause is being run.


When we pass, a SELECT query it executes under some phases. That includes

1) Checking by Server Process - Which type of Query is this - Sql or Pl/sql.
2) If sql - server process puts the code in sql area available under library cache under shared pool.
3) If pl/sql - server process puts the sql code in sql area and pl code in pl area available under library cache area under shared pool.
4) Now Parsing (Syntax, Privileges on user passing the query checks)
5) Check if execution plan is already available or not.
6) if not creates a execution plan on behalf of available statistics, if yes, uses available execution plan.
7) checks if the data blocks contains required data are available in buffer cache or not.
8) if yes, server process pick the data from BC and return to the user. If not server process reads the data blocks from data files and put the data blocks into buffer cache and return to the user.




10 comments:

  1. Nice explanation its too good work

    ReplyDelete
    Replies
    1. Welcome Rajeswar.
      https://tipsfororacle.blogspot.in/p/homepage.html?m=1

      Delete
    2. Hi Rajeshwar,

      in which reference you are saying that select columns are not referenceable in where clause..I didn't get your clear message .can you pls elaborate more by example..a simple eg
      select deptno ,empno from emp where deptno=10;

      Delete
  2. query processor actually pick those values from the specified tables and not from what is mentioned in Select.

    ReplyDelete
  3. Really nice blog, very infromative. You can refer more topics related to SQL like SQL Commands and Advanced SQL from here for future articles
    thanks !

    ReplyDelete
  4. I think there is a need to look for some more SQL based operations and hence finally one can establish and find solutions for his problems.

    SQL Server Load Rest Api

    ReplyDelete

  5. Those guidelines additionally worked to become a good way to recognize that other people online have the identical fervor like mine to grasp a great deal more around this condition. and I could assume you are an expert on this subject. Same as your blog i found another one Oracle Fusion Financials.Actually I was looking for the same information on internet for Oracle Financials Cloud and came across your blog. I am impressed by the information that you have on this blog. Thanks a million and please keep up the gratifying work.

    ReplyDelete
  6. I'd like to express my gratitude for the time and work you put into creating this essay.
    I'm looking for more of the same from you in the future. IAPPC, a leading Netsuite Partner in India for ERP installation and solution provider, provides end-to-end implementation services and support to meet the organization's demands.

    ReplyDelete
  7. Thank you Sir, nice blog.
    Sir, I have a doubt regarding query processing order.
    I was under the impression that "WHERE" clause gets executed before "GROUP BY" clause, request you to please let me know if my understanding is correct or not ?

    ReplyDelete
  8. As per your order joins done before where clause. if that is the case then how it work when we join two table based on refrencing key in where clause? in that case without where clause it will not be able to join the table.
    e.g
    select a.name, b.age from tab1 a, tab2
    where a.id=b.id

    ReplyDelete