sql - How to split up a massive data query into multiple queries -
sql - How to split up a massive data query into multiple queries -
i have select rows table millions of rows (to preload coherence datagrid.) how split query multiple queries can concurrently executed multiple threads?
i first thought of getting count of records , doing:
select ... rownum between (packetno * packetsize) , ((packetno + 1) * packetsize)
but didn't work. i'm stuck.
any help appreciated.
if have enterprise edition license, easiest way of achieving objective parallel query.
for one-off or advertisement hoc queries utilize parallel hint:
select /*+ parallel(your_table, 4) */ * your_table /
the number in hint number of slave queries want execute; in case database run 4 threads.
if want every query issued on table parallelizable permanently alter table definition:
alter table your_table parallel (degree 4) /
note database won't utilize parallel query; optimizer decide whether it's appropriate. parallel query works total table scans or index range scans cross multiple partitions.
there number of caveats. parallel query requires have sufficient cores satisfy proposed number of threads; if have single dual-core cpu setting parallel grade of 16 isn't going magically speed query. also, need spare cpu capacity; if server cpu bound parallel execution going create things worse. finally, i/o , storage subsystems need capable of satisfying concurrent demand; sans can remarkably unhelpful here.
as in matters of performance, crucial undertake benchmarking against realistic volumes of info in representative environment before going production.
what if don't have enterprise edition? well, possible mimic parallel execution hand. tom kyte calls "do-it-yourself parallelism". have used technique myself, , works well.
the key thing work out total range rowids apply table, , split them across multiple jobs. unlike of other solutions proposed in thread, each job selects rows needs. mr kyte summarized technique in old asktom thread, including vital split script: find here.
splitting table , starting off threads manual task: fine one-off rather tiresome undertake frequently. if running 11g release 2 ought know there new pl/sql bundle dbms_parallel_execute automates us.
sql oracle select
Comments
Post a Comment