Home » SQL & PL/SQL » SQL & PL/SQL » How to analyze complex sql queries (11G)
How to analyze complex sql queries [message #644787] Tue, 17 November 2015 14:26 Go to next message
gorants
Messages: 85
Registered: May 2014
Location: ATL
Member
Hello All,

How you doing. Not sure if my question makes sense, In my application we have huge/complex queries written by DB team. It was always hard to me to understand the logic. what is the better way if i want to be in a position to understand and writing complex logic.

Appreciate your inputs

Thanks
Re: How to analyze complex sql queries [message #644788 is a reply to message #644787] Tue, 17 November 2015 14:35 Go to previous messageGo to next message
Michel Cadot
Messages: 68643
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Ask them to write comments inside the SQL statements.
There are some chances they see the queries are not correct or optimal. Smile

Re: How to analyze complex sql queries [message #644821 is a reply to message #644788] Wed, 18 November 2015 06:39 Go to previous messageGo to next message
pablolee
Messages: 2882
Registered: May 2007
Location: Scotland
Senior Member
Michel Cadot wrote on Tue, 17 November 2015 20:35

Ask them to write comments inside the SQL statements.
There are some chances they see the queries are not correct or optimal. Smile


In addition to this, I personally find that graphically representing the query can be very helpful.
Start with just how the tables involved join together, what columns are used, etc etc.
once I can visualise that, track a single row through the query, looking at what data is picked up and transformed through each of the tables.
Also, you can often simplify the queries, break them down into different component parts. Understand those parts, then see how they fit together.
Re: How to analyze complex sql queries [message #644823 is a reply to message #644821] Wed, 18 November 2015 06:51 Go to previous messageGo to next message
Michel Cadot
Messages: 68643
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Quote:
break them down into different component parts.


Yes, use of factoring (WITH) clause greatly help in the opposite of multiple levels of "FROM (SELECT..." clauses.

Re: How to analyze complex sql queries [message #644845 is a reply to message #644823] Wed, 18 November 2015 12:42 Go to previous message
gorants
Messages: 85
Registered: May 2014
Location: ATL
Member
Thanks for your valuable inputs. I know it is not easy to learn over night, i will go through online resources and learn.
Previous Topic: Results Set based on Dynamic Date stored in variable
Next Topic: How to display multiple records in a single row
Goto Forum:
  


Current Time: Tue Apr 23 16:52:34 CDT 2024