Stale or Locked Optimizer Statistics [Optimizer Condition]Optimizer Condition · Stale or Locked Optimizer Statistics
An optimizer condition where dictionary statistics remain stale (STALE_STATS='YES') or blocked from refreshing by forgotten statistics locks (STATTYPE_LOCKED) despite major growth or value-range drift in underlying tables or partitions. Costing against outdated row counts or expired HIGH_VALUE ranges leads directly to severe cardinality errors.
Diagnostic Disambiguation Matrix
Verified operational error scenario under Oracle 19c, 26ai: An optimizer condition where dictionary statistics remain stale (STALE_STATS='YES') or blocked from refreshing by forgotten statistics locks (STATTYPE_LOCKED) despite major growth or value-range drift in underlying tables or partitions. Costing against outdated row counts or expired HIGH_VALUE ranges leads directly to severe cardinality errors.
Not an error belonging to an external database engine or unrelated subsystem; native to this catalog.
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
An optimizer condition where dictionary statistics remain stale (STALE_STATS='YES') or blocked from refreshing by forgotten statistics locks (STATTYPE_LOCKED) despite major growth or value-range drift in underlying tables or partitions. Costing against outdated row counts or expired HIGH_VALUE ranges leads directly to severe cardinality errors.
Severity Context: Medium / High — Gradual statistics drift eventually crosses optimizer thresholds, triggering sudden cliff-edge plan regressions.
▸2. Possible Causes (Confirm Root Cause via Evidence)
- •Possible cause (must be verified): A table locked with DBMS_STATS.LOCK_TABLE_STATS during an older incident and never unlocked or updated.
- •Possible cause: Automated statistics maintenance windows timing out before reaching large tables.
- •Possible cause: Default 10% STALE_PERCENT threshold taking weeks to trigger on multi-hundred-million-row tables.
- •Possible cause: Bulk loads or newly created partitions left without post-load statistics gathering.
▸3. Read-Only Diagnostic Steps
- 1Query DBA_TAB_STATISTICS for critical schema tables where STALE_STATS='YES' or STATTYPE_LOCKED IS NOT NULL.
- 2Inspect DBA_TAB_MODIFICATIONS for accumulated inserts, updates, and deletes since LAST_ANALYZED.
- 3Compare column HIGH_VALUE bounds in DBA_TAB_COL_STATISTICS against current maximum values in growing date/sequence columns.
-- ORA-CAT-17 | Core Oracle Database (EE & SE2) — no extra pack required. | Syntax-Reviewed (Not Runtime-Tested)
-- READ-ONLY | License-free core DBA_ view
SELECT owner, table_name, partition_name, num_rows,
last_analyzed, stale_stats, stattype_locked
FROM dba_tab_statistics
WHERE owner NOT IN ('SYS','SYSTEM','DBSNMP','OUTLN','WMSYS','XDB')
AND (stale_stats = 'YES' OR stattype_locked IS NOT NULL)
ORDER BY last_analyzed NULLS FIRST
FETCH FIRST 30 ROWS ONLY;▸4. Controlled Remediation Options
- •Audit locked tables; remove unintended locks and capture critical SQL Plan Baselines before refreshing statistics.
- •Configure INCREMENTAL=TRUE and tighter STALE_PERCENT (e.g., 1–5%) preferences on very large partitioned tables.
- •Validate fresh statistics safely using pending statistics (PUBLISH=FALSE) before exposing them globally.
▸5. Related Terms & References
- •Related Terms: Optimizer Statistics, Cardinality, SQL Plan Regression, SQL Plan Baseline
- •Main Technical Guide: Oracle SQL Plan Regression: Detection, Diagnosis and Stabilization
- •Official Documentation: Oracle Documentation
ORACLE Diagnostic Standards, Operational Reliability, and Interview Readiness.
This error is not merely a config typo; it is a lesson in consistency models, concurrency architectures, and capacity planning.
- Articulate error symptoms, distinguishing diagnostics, and safe recovery steps.
- Implement architectural safeguards to permanently eliminate root causes.
What Senior Interviews Ask About This Error?
Q1When this error (Stale or Locked Optimizer Statistics [Optimizer Condition]) surfaces in production, what must be inspected within the first 60 seconds?Mid
Before restarting servers blindly, inspect active sessions, locks, and recent engine logs to identify the true failure mode.
Q2Which metrics should be integrated into alerting to prevent recurrence of this issue?Senior
Set up early warning metrics targeting connection pools, memory grants, disk headroom, or lock queues with actionable thresholds.
Q3How should applications defensively guard against this database failure?Junior
Implement idempotent retry loops with backoff, strict query timeouts, verified connection pool bounds, and structured error logging.
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.