0

As I am not so clear in scenarios of when to use stored procedures instead of functions ,

I have a scenario where a function is already being used, but as it takes much time to execute in a stored procedure, now can I replace this function (which returns a string) with a procedure?

Can any one please explain me what happens when replacing a function with a stored procedure?

Thanks in advance.

1 Answer 1

2

There's no magically performance boost from either one. If they contain the same code, they'll have the same performance.

I'd say, keep it as a function unless or until you reach a limitation of functions - e.g. if you want to actually change database state.

Functions are more composable - you can call them directly from within other statements such as SELECT - whereas stored procedures have to be explicitly called.

Sign up to request clarification or add additional context in comments.

5 Comments

But in my scenario this function is taking 500,000 lines at once as input and could not execute faster, how should i control the flow or increase performance.
@Pink - examine the execution plan, consider adding appropriate indexes. There's no magic wand.
Indexes to tables which are used in functions?
Can i divide output lines into different slots and supply it to functions? is that possible?
The system will automatically parallelize a plan if it believes that it would be beneficial to do so.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.