How to analyze complex sql queries [message #644787] |
Tue, 17 November 2015 14:26 |
|
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 #644821 is a reply to message #644788] |
Wed, 18 November 2015 06:39 |
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.
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.
|
|
|
|
|