Setting a value for LIMIT while using bulk collect

后端 未结 1 981
傲寒
傲寒 2020-12-10 09:37

I wanted to know if we have any technique by which we can calculate the value which needed to be set for a LIMIT clause of bulk collect operation. For example below, lets s

相关标签:
1条回答
  • 2020-12-10 10:18

    Use an implicit cursor in a cursor FOR LOOP. It makes the code simpler and the default value of 100 is almost always good enough.

    I've seen a lot of people waste a lot of time worrying about this. If you think about why bulk collect improves performance you will understand why large numbers won't help.

    Bulk collect improves performance by reducing the context switches between SQL and PL/SQL. Imagine the highly-unlikely worst case scenario, where context switching uses up all the run time. A limit of 2 eliminates 50% of the context switches; 10 eliminates 90%; 100 eliminates 99%, etc. Plot it out and you'll realize it's not worth finding the optimal limit size:

    Use the default. Spend your time worrying about more important things.

    0 讨论(0)
提交回复
热议问题