Does parameter passing degrade stored procedure performance? - SQLA most recent 30 from http://sqla.stackexchange.com 2010-03-20T11:56:10Z http://sqla.stackexchange.com/feeds/question/51 http://www.creativecommons.org/licenses/by-nc/2.5/rdf http://sqla.stackexchange.com/questions/51/does-parameter-passing-degrade-stored-procedure-performance Does parameter passing degrade stored procedure performance? Jon Greisz 2009-11-12T17:02:00Z 2009-11-21T11:30:02Z <p>I've got a complicated calculation that involves several lines of my stored procedure. This is in several places throughout the stored procedure. So I'd like to encapsulate it, unfortunately it references 30+ variables, which would then need to become parameters.</p> <p>So my question is how much performance degradation do we see if we call procedures with lots of parameters?</p> <p>This is one of the reasons that I've been advocating records for several years now. In Oracle I'd create a record with the data elements, and just pass one parameter. Or use a package and package level variables. </p> <p>In SQL Anywhere the best I could come up with was console variables, and I don't know if they add additional overhead or not.</p> <p>Thanks, Jon</p> http://sqla.stackexchange.com/questions/51/does-parameter-passing-degrade-stored-procedure-performance/52#52 Answer by Zote for Does parameter passing degrade stored procedure performance? Zote 2009-11-12T19:47:29Z 2009-11-12T19:47:29Z <p>I think that's an question for sybase/ianywhere people. <strong>But in MY opinion</strong>, parameters have low cost than insert/select. You can try "<em>table way</em>" using <strong><em>Global Temporary Table</em></strong>.</p> http://sqla.stackexchange.com/questions/51/does-parameter-passing-degrade-stored-procedure-performance/56#56 Answer by Breck Carter for Does parameter passing degrade stored procedure performance? Breck Carter 2009-11-13T04:59:09Z 2009-11-13T04:59:09Z <p>I'm not Sybase/iAnywhere either, but I agree with Zote. I have written many procedures with many parameters over the years, and run the execution profiler many times, and <strong>never</strong>, <strong>ever</strong> have I seen simple parameter passing to be a performance bottleneck.</p> <p>Yes, CALL statements do frequently show up with peaks in the profiler, but as far as I can tell that's because of a [cough] quirk whereby all the time spent inside the procedure is shown twice, once inside the procedure and again totalled up and allocated to the outer CALL.</p> <p>In Oracle, do you know whether or not using a record is more, or less, efficient, or makes no difference? From actual testing and measurement?</p> <p>And was your primary reason for using records one of performance, or convenience?</p> <p>BTW, I'm guessing records or something like it are on iAnywhere's possible-to-do list... for reasons of convenience rather than performance.</p> <p>Here's my advice: Write your code in the way that's easiest for you, at the same time being reasonably readable and maintainable, and then do a stress (performance) test. If it runs quickly, stop, don't change anything. If it runs slowly, use the profiler to look for bottlenecks. I will bet that 90% of the time will show up against SELECT, INSERT, UPDATE and DELETE statements and the like... stuff that hits the disk. </p> <p>If you heavily use proxy tables, then that's where 100% of the time will go ( just kidding! :)</p> <p>Breck Grinning Running And Ducking</p> <p>PS ...or stuff that locks-and-blocks, that's a performance killer by definition.</p>