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.

So my question is how much performance degradation do we see if we call procedures with lots of parameters?

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.

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.

Thanks, Jon

asked 12 Nov '09, 17:02

Jon%20Greisz's gravatar image

Jon Greisz
571979
accept rate: 0%

edited 15 Mar '13, 19:01

Mark%20Culp's gravatar image

Mark Culp
23.2k9132273


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 never, ever have I seen simple parameter passing to be a performance bottleneck.

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.

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?

And was your primary reason for using records one of performance, or convenience?

BTW, I'm guessing records or something like it are on iAnywhere's possible-to-do list... for reasons of convenience rather than performance.

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.

If you heavily use proxy tables, then that's where 100% of the time will go ( just kidding! :)

Breck Grinning Running And Ducking

PS ...or stuff that locks-and-blocks, that's a performance killer by definition.

permanent link

answered 13 Nov '09, 04:59

Breck%20Carter's gravatar image

Breck Carter
26.3k430600866
accept rate: 21%

From a code readability and maintainability point of view, parameter lists are by far the best way to communicate between procedures. Any other mechanism serves to hide what's really going on, including records, and globals (CREATE VARIABLE) might be the worst. In the old days this was called "coupling".

(13 Nov '09, 05:02) Breck Carter

Hey, guess what? you can't edit your own comments, at least I can't see how. Anyway, I was thinking my rant about globals might have seemed harsh... I am not as dogmatic as that comment might seem. Question for you: How did you like the experience of using lots of CREATE VARIABLE statements? I have only ever used them for special purposes, like passing parameters to triggers ( go ahead, all you Anti-Global people, tell me there's another way to do that :)

(13 Nov '09, 07:46) Breck Carter
Comment Text Removed

I'm not a big fan of globals for this, especially with create variable. We've used it in a few other places with success. But error handling leaving needs to be real good, or the variables are left active, so it just adds headaches.

In this case we're just trying to clean up some code where we have a complicated 20 line expression in multiple spots within the code. I've converted it to a stored procedure and it seems to be working fine with the parameters, so I'll take your advice and leave it as is. Thanks, Jon.

(13 Nov '09, 13:07) Jon Greisz

I didn't answer the Oracle question. I have not performed performance testing, so cannot answer that question. I'd say we use the records mostly for convenience. The ability to declare a record with

%ROWTYPE and <cursor name="">%ROWTYPE is very convenient. Especially with cursors as adding to the select no longer means changing the FETCH statements and declaring new variables. But overall it just seems cleaner, you're right it may hide some code, but parameter lists of 60 parameters just seem wrong or something. :)

(13 Nov '09, 13:18) Jon Greisz

I'd still love to know how the parameters are passed, especially strings, and whether it could cause a performance issue. This particular expression is called hundreds of thousand times, so just want to make sure that I'm not going to need to rewrite it once we start load testing it.

(13 Nov '09, 13:19) Jon Greisz

Can you put together a test case, a loop with a call to an empty procedure, then just run it to see what happens? As for the "how parameters are passed", I suggest posting a new question asking exactly that, leaving out mention of performance; perhaps the folk(s) responsible for that part of the engine will reveal all... that's who you should aim the question at. I know I would love to know the details.

(14 Nov '09, 09:07) Breck Carter

Also... please post another new question with the Title "Product Suggestion: Please implement xxx". Do it quickly, and you will be the first to establish a new SQLA question type! ...which will get described in the FAQ. Provide a business case for why you want it (iAnywhere is a for-profit company), maybe a link to the Oracle docs.

(14 Nov '09, 09:13) Breck Carter
More comments hidden
showing 4 of 7 show all flat view

I think that's an question for sybase/ianywhere people. But in MY opinion, parameters have low cost than insert/select. You can try "table way" using Global Temporary Table.

permanent link

answered 12 Nov '09, 19:47

Zote's gravatar image

Zote
1.7k364050
accept rate: 43%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×242
×106
×24
×19

question asked: 12 Nov '09, 17:02

question was seen: 2,443 times

last updated: 15 Mar '13, 19:01