Oracle Time Model Queries: v$sys_time_model Monitoring
Purpose
The v$sys_time_model and v$sess_time_model views show where the database spends its time, in microseconds. The queries below list that time largest first, so a DBA can tune the largest time consumer first. Time model statistics measure DB time, which represents the total time spent in database calls by foreground sessions and serves as an indicator of total instance workload. Compare DB CPU with DB time to see whether the instance is CPU bound or waiting.
Code Breakdown
Query 1: System Time Model
1set lines 100 pages 999
2select stat_name
3,value
4from v$sys_time_model
5order by value desc
6/
This query retrieves system-wide accumulated times for various database operations. The v$sys_time_model view displays instance-level statistics that are cumulative since database startup. The query formats output to 100 characters per line and 999 pages, selects the statistic name and its value, then orders results by value in descending order to show which operations consume the most time.
Query 2: Session Time Model
1set lines 100 pages 999
2select stat_name
3,value
4from v$sess_time_model
5where sid = '&sid'
6order by value desc
7/
This query retrieves session-level accumulated times for a specific session identifier. The v$sess_time_model view provides the same statistics as the system view but filtered to a single session, allowing administrators to drill down into specific session behavior. The query uses a substitution variable (&sid) to specify which session to analyze.
Key Points
Time values in both views are stored as 8-byte integers in microseconds and can hold approximately 580,000 years of data before wrapping. All time statistics are cumulative, meaning they accumulate from instance startup for system views or from session start for session views. Background process time is excluded from statistics unless the statistic specifically tracks background processes.
The most important time model statistic is DB time, which equals DB CPU plus non-idle wait time. This formula helps identify whether sessions are spending time actively working on CPU or waiting for resources. Timed operations buffer at most 5 seconds of time data, meaning long-running operations may have up to 5 seconds of unaccounted time.
AWR reports include time model statistics in a dedicated section. Compare reports before and after a change to check the result.
Insights
All time model statistics use time units, so they can be compared directly. The hierarchical relationship between statistics forms trees where child statistics are contained within parent statistics.
Sessions with a high wait percentage spend more time waiting than running on CPU. For system-level analysis, ordering by value descending immediately reveals which operations consume the most database time.
The time model method for performance tuning focuses on removing excess DB time by identifying the largest potential improvements within scope.
How Time Model Statistics Work
Time model statistics form two distinct trees that show containment relationships between parent and child statistics. The first tree starts with background elapsed time, while the second tree begins with DB time. Under DB time, major categories include DB CPU, connection management, sequence load, SQL execute, parse time, PL/SQL execution, and Java execution elapsed time.
Important child statistics under parse time include hard parse elapsed time, which further breaks down into sharing criteria and bind mismatch categories. The breakdown shows why parsing is slow.
Parse time elapsed includes both soft and hard parse time, while SQL execute elapsed time for select statements includes the time spent fetching query results.
Using Time Model for Performance Diagnosis
Administrators should calculate the difference between cumulative values at the start and end of a period when analyzing performance. This shows load in that window, not since startup.
To identify sessions spending excessive time waiting, calculate wait percentage by subtracting DB CPU from DB time and dividing by DB time. Sessions with wait percentages above 90% are spending most of their time blocked rather than executing. These sessions become prime candidates for further investigation using views like v$session, v$active_session_history, or v$session_wait.
The DB time method follows a systematic process: identify the performance issue, scope it, set goals, capture data, investigate DB time distribution, modify the system for largest gain, and evaluate against goals.
References
Oracle Official Documentation - V$SYS_TIME_MODEL - Complete reference for the system-wide time model view including column descriptions and statistic definitions.
Oracle Official Documentation - V$SESS_TIME_MODEL - Detailed documentation for session-level time model statistics with relationship trees and statistic explanations.
Oracle Time Model Statistics Guide - Overview of time model statistics and their role in measuring database performance.
Measuring Database Performance - Oracle Documentation - Official guide covering database statistics, time model statistics, and performance measurement techniques.
Modeling Oracle Time - Database Journal - Tutorial explaining Oracle's time model and how to use V$SYS_TIME_MODEL and V$SESS_TIME_MODEL for performance analysis.
What Is Oracle DB Time, DB CPU, and Non-Idle Wait Time - Detailed explanation of DB time calculation and the relationship between DB CPU and wait time.
Identify Top Waiting Sessions Using Time Model Stats - Practical guide with SQL examples for identifying sessions with high wait percentages.
DB Time Performance Tuning: Theory and Practice - Comprehensive presentation covering the DB time method for performance tuning and practical implementation.
Posts in this series
- Oracle AWR Snapshots: Query dba_hist_snapshot
- Oracle AWR Report Generation Using awrrpt.sql Script
- Oracle AWR Interval and Retention: DBA_HIST_WR_CONTROL
- Oracle AWR Snapshot Interval: modify_snapshot_settings
- Oracle AWR: Change Retention Period to 14 Days
- Oracle AWR Manual Snapshot: DBMS_WORKLOAD_REPOSITORY
- List All Oracle AWR Baselines Using DBA_HIST_BASELINE
- Oracle AWR Baseline with DBMS_WORKLOAD_REPOSITORY
- How to Remove an Oracle AWR Baseline Using DROP_BASELINE
- Oracle: Enable or Disable GATHER_STATS_JOB
- Oracle Time Model Queries: v$sys_time_model Monitoring
- Oracle ASH Report: Generate with ashrpt.sql
- Query Historical ASH Beyond Memory with DBA_HIST_ACTIVE_SESS_HISTORY