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 )