February 12, 2008 at 4:22 am
Hi,
Does anyone know of any tools that give a code complexity analysis value of t-sql or dts code?
Something similar to Mcabe/Cyclomatic ?
regards
George
February 12, 2008 at 2:59 pm
I don't know what a "code complexity analysis" is. Can you clarify?
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
February 13, 2008 at 10:24 am
February 14, 2008 at 12:03 pm
I'm not sure such is possible/applicable in an SQL database (regardless of which flavor of SQL we're talking about; Oracle, MS, whatever).
One of the main things is the number of logical branches for the code. How do you measure that when it can change depending on the number of rows in related tables?
For example:
select 1
and
select *
from dbo.Table1
inner join dbo.Table2
on table1.id <= table2.maxT1id
where table1.date > getdate()
Neither one has any "if" type statements in it. Does that mean they are both complexity 1?
Or do you count Where clauses as if they were "if" statements? In which case, the first is complexity 1 and the second is complexity 3 (one join "on" and one "where").
In fact, the second one might be really simple for the server to resolve, if table1 and table2 both have 2 rows, or incredibly complex to resolve, if both have millions of rows. How do you measure that complexity?
As far as the "paths" for the code, do you count what happens when the server changes it's mind about how to perform the join (nested loops, merge, or even one of the various flavors of hash join)? How can a piece of software judge before-hand what possible options the server has, when it's based on table statistics?
I think the complexity measure has value in procedural or OO code, but I'm not sure it's even possible in SQL, where you don't even write the code yourself, you just tell the server what to do and it figures out which code to use.
If you can't find such a product with a simple Google search, it's probably because it doesn't exist, because it really can't be done meaningfully. I could easily be wrong, this is just my initial take on the subject.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply