1

What options are there for implementing workload balancing in a PL/SQL stored procedure. I'm not talking about configuring the server to handle workload, I'm talking about implementing such a feature into a specific stored procedure.

Lets say I have a procedure that takes in data, reads the data, processes it and then returns a result. If the data-set is extremely large, other users of the system will feel the performance drop when a greedy user sends in their large data-set to be processed.

One solution would be to use a wait command every x iterations (if the data-set was being read in a loop-like fashion.) to allow other users requests to process for a bit during the large request is being handled.

Are there any other ways that this kind of thing could be implemented in a single PL/SQL procedure/package?

1
  • 3
    Oracle Resource Manager can do it: docs.oracle.com/cd/E11882_01/server.112/e10595/… . You can define resource groups with different priorities, and automatically swich the session from one gorup to another with lower priority when the session meets some criteria (for example a query runs longer than X minutes and so on).
    – krokodilko
    Sep 20, 2013 at 15:01

1 Answer 1

1

If the data you are fetching is very large we can use collection and bulk collect like this:

CREATE OR REPLACE

function employee_job return id_tabl as

 emp_table  id_tabl;

 begin

 select job_id 

 bulk collect into emp_table from employees;

 return emp_table;

 end employee_job;

Using such type of code will reduce the context switching and will improve the performance.

Please revert back if you are not satisfied by the answer or if am not able to follow your question correctly.

1
  • To make your code sections look like code you can highlight them and click the {} icon. It makes it easier to read. ;) Dec 3, 2013 at 6:08

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.