Question

I am looking into some stored procedures and the code is more or less non-readable e.g. there are 15 main joins in one statement and the level of nesting of the subqueries is e.g. 7 in order to simply define one of the tables used in the joins... If one counts the joins in the subqueries then there are many more joins... Hope it makes sense...

I do not think a human has written these SPs and I think they have generated the code and copy-pasted it in the SP template... Does this sound right?

What are these tools called? So I am trying to refactor these and I was first annoyed and thought what idiot writes code like this but now like I said I think it is autogenerated... By autogenerated I mean a drag and drop interface.

Is my inference correct based on the description above? If you could comment of performance that would be great. My understanding is that these tools are performance killers...

Was it helpful?

Solution

Trying to reverse engineering to find the tool will take too much time and you will possibly never find the solution. Debug this through an Agile methodology:

“The most efficient and effective method of conveying information to and within a development team is face-to-face conversation”

So go to your colleagues and don't be afraid to ask:

"Are we using an automated tool or a drag-n-drop tool to create queries? I ask this because they really look machine-made to me"

And the result can be:

  1. Yes, they are written by a tool: and show to your colleagues how painful this choice can be for your performances
  2. No, they are written by Tom: and talk to Tom and say "Hey, Tom, I was having an hard time reading through your code, is there any way I can help you..."

Be nice to people. Machines cannot change but humans can.

OTHER TIPS

The only thing I can think you can do that might be helpful is create a DDL trigger to log who creates stored procedures in that database to a table. That way if someone was using a tool to actually generate the procedure you might see a non-normal user account. But this is a bit of a stretch.

Licensed under: CC-BY-SA with attribution
Not affiliated with dba.stackexchange
scroll top