What is parallel query execution?
In a standard database setup, a SQL query is like a single chef in a kitchen. No matter how large the order is, that one chef handles everything—chopping the vegetables, grilling the steak, and plating the dish—one step at a time.
Parallel Query Execution changes the game by hiring a team of chefs. It breaks a single SQL statement into smaller pieces and runs them simultaneously across multiple CPU cores.
When you execute a query in parallel, Oracle designates one process as the Query Coordinator (QC) and spawns several Parallel Execution (PX) Servers (also called Slaves).
The Coordinator: Acts as the "manager." It breaks the task apart, assigns it to the workers, and merges the final results to send back to the user.
The Workers: These processes do the heavy lifting (scanning blocks, joining rows, sorting data) in parallel.
If you have a Degree of Parallelism (DOP) of 4, Oracle will use 4 worker processes to scan different sections of the table at the same time.
Parallelism is not a "magic button" to make every query faster. It is designed for Large Scale Operations.
Full Table Scans: Reading a 1-Terabyte table.
Massive Joins: Connecting two multi-million row tables.
Large Sorts: Performing a GROUP BY or ORDER BY on millions of records.
Index Creation: Building an index on a massive table.
Data Loading: Bulk inserts using INSERT /*+ APPEND */.
OLTP Transactions: If your query only fetches one row by an ID, the overhead of managing parallel workers will actually make the query slower.
Highly Congested Systems: If your CPU is already at 90% usage, adding parallel workers will just cause "CPU starvation" for other users.
There are three ways to tell Oracle to go parallel:
You can force a specific query to be parallel using a hint:
SELECT /*+ PARALLEL(8) */ * FROM large_sales_table;
You can tell Oracle that a specific table is so large that it should always be queried in parallel:
ALTER TABLE large_sales_table PARALLEL 4;
Modern Oracle versions (12c, 19c, 23c) can automatically decide if a query is "heavy" enough to merit parallelism based on the estimated cost.
| Feature | Serial Execution | Parallel Execution |
| Resources | Uses 1 CPU process. | Uses multiple CPU processes. |
| Execution | Step-by-step (Sequential). | Simultaneous (Concurrent). |
| Ideal For | Quick lookups, small tables. | Reporting, Data Warehousing, VLDBs. |
| Overhead | Minimal. | High (Startup and coordination time). |
If you see your query is running in parallel but it's still slow, check your session waits. Look for PX Deq: Execute Reply. This usually means the Coordinator is waiting for the worker processes to finish their "slices" of the work. If one worker gets a much larger slice than the others (data skew), the whole query waits for that one "slow chef."
[ ] Hardware: Ensure you have multiple CPUs and fast I/O.
[ ] Partitioning: Parallelism works best with partitioned tables (each worker can take one partition).
[ ] Memory: Ensure your PGA is large enough, as parallel processes need memory for sorting and hashing.
Did you know you can also run UPDATE and DELETE in parallel? You just have to enable it for your session first:
ALTER SESSION ENABLE PARALLEL DML;
UPDATE /*+ PARALLEL(4) */ massive_table SET status = 'PROCESSED';
Without that ALTER SESSION command, Oracle will only perform the SELECT part in parallel, but the actual UPDATE will remain serial!