Question

Is it better to put all operations belonging to one table (insert, update, delete, select, search, ...) in one stored procedure or in multiple procedures?

Is that will affect the speed and the performance of the execution?

Was it helpful?

Solution

I would make a stored procedure for each operation mainly for maintainability. Each store procedure will be coherent to its task. If you have all the actions in one stored procedure then its going to contain conditions which will bulk up the lines of code and could increase the number of variables that really could make it difficult to fix errors.

Also the parameters, you could have to supply the parameters for all the actions regardless of whether the given action actually needed them or not. ie. delete action would only require the identifier, but you have to supply other parameters because they are required for insert and update actions

OTHER TIPS

You should put them all in their own individual procedures.

There will be a minimal effect on speed due to removal of logic code, and an increase of clarity of code.

You should put all individual operations in a distinct stored procedure. It will make your queries faster if they don't have to weed through un-necessary logic to get to the desired logic.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top