简体   繁体   中英

How do I parallelise a simple SELECT query?

Say I have the classic:

select * from employees where dob < to_date('10/10/1985', 'DD/MM/YYYY');

The table is huge, so I want to parallelise this query.

Going by what I can see here:

http://docs.oracle.com/cd/B10500_01/server.920/a96524/c20paral.htm#13255

Essentially what we're wanting to do is arbitarily chop the table into n parts, and run our select statement on each chunk on a different thread, then join them together at the end.

  1. Is parallelisation appropriate here?
  2. How would I write the query?

Try this:

select /*+ PARALLEL(4) */ * from employees 
where dob < to_date('10/10/1985', 'DD/MM/YYYY');

See more from Oracle Hint .

See also this answer to see why PARALLEL did not applied on your SQL statement.

/*+parallel(8)*/

has decreased by search time from 16secs to 3 secs. So, I could definitely say it works :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM