Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Reg: Dividing data into buckets -

915396Feb 9 2016 — edited Feb 10 2016

Hi Experts,

I am trying, but not able to think through this problem - I want to divide my data set into equally sized buckets. You can think of this as "load balancing", wherein i'm trying to divide my entire data set into N process threads (parallel).

Example -

with skool as (

      select 1 section, 50 students from dual union all

      select 2 section, 70 students from dual union all

      select 3 section, 20 students from dual union all

      select 4 section, 10 students from dual union all

      select 5 section, 80 students from dual union all

      select 6 section, 30 students from dual union all

      select 7 section, 50 students from dual

)

----

select s.*, ntile(3) over(order by s.students desc) nt from skool s

order by nt;

This's not working though...Here, N=3 (this can be hard-coded).

Once the entire data is bucketed, the individual buckets can be passed to its corresponding process thread.

Say, if we divide the above data-set into Odd & Even buckets...

Process-thread 1 -- Sections {1, 3, 5, 7}

Process-thread 2 -- Sections {2, 4, 6}


Any pointers ? Help is much appreciated.

Thanks and Regards,

-Ranit

( on Oracle 11.2.0.4.0 )

This post has been answered by Paulzip on Feb 9 2016
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 9 2016
Added on Feb 9 2016
16 comments
4,221 views