Temp Tablespace Spill (Hash/Sort Workarea Exhaustion) [Resource Contention]Resource Contention · Temp Tablespace Spill (Hash/Sort Workarea Exhaustion)
Resource contention occurring when Hash Join, ORDER BY, GROUP BY, or window-sort workareas exceed available session PGA memory and spill to TEMP tablespace as one-pass or multi-pass disk operations. Even before hitting ORA-01652, heavy "direct path write temp" and "direct path read temp" waits dramatically inflate Elapsed Time and storage I/O load.
Diagnostic Disambiguation Matrix
Indicates that the ORACLE storage volume, tablespace, disk capacity, or memory quota has hit its ceiling.
Not a SQL syntax or table schema bug; represents physical or logical capacity exhaustion.
The error string is a symptom, not the root cause. Do not restart database servers blindly! Execute the read-only diagnostic queries below to determine the actual failure mode before attempting session terminations or configuration changes.
▸1. Description & Context
Resource contention occurring when Hash Join, ORDER BY, GROUP BY, or window-sort workareas exceed available session PGA memory and spill to TEMP tablespace as one-pass or multi-pass disk operations. Even before hitting ORA-01652, heavy "direct path write temp" and "direct path read temp" waits dramatically inflate Elapsed Time and storage I/O load.
Severity Context: High — Multi-pass TEMP spills can slow queries by 10x+ and saturate underlying temporary storage I/O.
▸2. Possible Causes (Confirm Root Cause via Evidence)
- •Possible cause (must be verified): Cardinality under-estimation causing the CBO to place a large row source on the Hash Join build side or undersize PGA allocation.
- •Possible cause: Concurrent large hash/sort workloads competing under an undersized PGA_AGGREGATE_TARGET / PGA_AGGREGATE_LIMIT.
- •Possible cause: A SQL Plan Regression dropping an ordered index path in favor of full scan + SORT ORDER BY.
- •Possible cause: Unnecessary wide columns carried through sort/hash buffers.
▸3. Read-Only Diagnostic Steps
- 1Inspect V$SQL_WORKAREA_ACTIVE and V$SQL_WORKAREA for MULTIPASS_EXECUTIONS, ONEPASS_EXECUTIONS, TEMPSEG_SIZE, and ESTIMATED_OPTIMAL_SIZE.
- 2Verify "direct path write temp" and "direct path read temp" wait totals in V$SYSTEM_EVENT.
- 3Review V$PGASTAT for PGA cache hit percentage and over-allocation counts.
- 4Examine Used-Tmp and OMem/1Mem columns in DBMS_XPLAN.DISPLAY_CURSOR (ALLSTATS LAST) for offending SQL_IDs.
-- ORA-CAT-18 | Core Oracle Database (EE & SE2) — no extra pack required. | Syntax-Reviewed (Not Runtime-Tested)
-- READ-ONLY | License-free core V$ view
SELECT sql_id, operation_type, policy,
ROUND(estimated_optimal_size/1024/1024, 2) AS est_opt_mb,
ROUND(last_memory_used/1024/1024, 2) AS last_mem_mb,
ROUND(last_tempseg_size/1024/1024, 2) AS last_temp_mb,
onepass_executions, multipasses_executions
FROM v$sql_workarea
WHERE last_tempseg_size > 0 OR multipasses_executions > 0
ORDER BY NVL(last_tempseg_size, 0) DESC, multipasses_executions DESC
FETCH FIRST 20 ROWS ONLY;▸4. Controlled Remediation Options
- •Fix cardinality misestimates driving inverted Hash Joins or enforce a verified SQL Plan Baseline.
- •Right-size PGA_AGGREGATE_TARGET guided by V$PGA_TARGET_ADVICE.
- •Prune unnecessary wide columns from sort/hash projections or eliminate sorts via appropriate indexing.
▸5. Related Terms & References
- •Related Terms: Cardinality, Execution Plan, Elapsed Time, Wait Event
- •Main Technical Guide: Oracle SQL Plan Regression: Detection, Diagnosis and Stabilization
- •Official Documentation: Oracle Documentation
ORACLE Capacity Planning, Autogrowth Configurations, and Memory Management.
This error is not merely a config typo; it is a lesson in consistency models, concurrency architectures, and capacity planning.
- Execute emergency space remediation procedures without risk of data loss.
- Integrate autogrowth thresholds and capacity alerts into central monitoring systems.
What Senior Interviews Ask About This Error?
Q1What architectural protections prevent database crashes during sudden storage exhaustion?Mid
Isolate data files, transaction logs, and backup staging onto independent physical volumes, pairing with proactive 80% disk capacity alerting.
Q2Why should autogrowth increments be configured as fixed sizes rather than percentages?Senior
Percentage autogrowth expands into massive multi-gigabyte allocations as files grow, stalling I/O. Fixed allocations (e.g. 512MB-1GB) ensure predictable latency.
Q3Why is manually deleting database files from the OS filesystem during an outage disastrous?Junior
It corrupts database catalog integrity, drives instances into SUSPECT or RECOVERY FAILED states, and makes data loss inevitable.
Senior DBA & SRE Career Roadmap
Explore database reliability milestones, incident response protocols, and architectural leadership.
More ORACLE Diagnostic Playbooks
Battle-tested triage guides for production incidents.
Oracle ORA-01653: Tablespace Extension & Step-by-Step Fix
Distinguishing ORA-01653, 01654, and 01652, tablespace capacity monitoring, datafile autoextend, and safe sizing with MAXSIZE.
Oracle ORA-00001: unique constraint violated Triage & Fix
Troubleshooting unique key collisions caused by out-of-sync sequences and bulk imports; sequence fast-forwarding and DML error logging.
Oracle ORA-00060: deadlock detected while waiting for resource Triage
Root cause analysis of cross-dependency deadlocks and missing foreign key index table locks via trace logs and serialized DML execution.