My Session I/O Analysis (vmyio.sql)
What This Script Does
Section titled “What This Script Does”This script analyzes I/O statistics specifically for the current user’s session, providing detailed information about block gets, consistent gets, physical reads, and block changes. It’s essential for understanding the I/O characteristics of your own session’s work, analyzing query efficiency, and troubleshooting performance issues from a session-specific perspective. The script shows cache efficiency and I/O patterns for the logged-in user’s activities.
The Script
Section titled “The Script”rem vsessio.sqlremttitle 'Session I/O'remset linesize 132remcol sid format a12 heading 'SID:SERIAL'col username format a12 heading 'USERNAME'col osuser format a10 heading 'OSUSER'col block_gets format b999,999,999 heading 'BLOCK|GETS'col consistent_gets format b999,999,999,999 heading 'CONSISTENT|GETS'col physical_reads format b999,999,999 heading 'PHYSICAL|READS'col block_changes format b99,999,999 heading 'BLOCK|CHANGES'col consistent_changes format b999,999,999 heading 'CONSISTENT|CHANGES'col hit_ratio format b9.000 heading 'HIT|RATIO'col log_phy format 999999 heading 'LOG/|PHY'col module format a15rembreak on reportcompute sum - of block_gets consistent_gets physical_reads block_changes consistent_changes - on reportremselect i.sid ||':'|| s.serial# sid, s.username, s.osuser, block_gets, consistent_gets, physical_reads, (block_gets + consistent_gets) / decode(physical_reads, 0, 1, physical_reads) log_phy, -- 1 - (physical_reads/decode(block_gets + consistent_gets, 0, 1, -- block_gets + consistent_gets)) hit_ratio, block_changes, consistent_changes, module -- added sep from v$session s, v$sess_io i where i.sid = s.sid and s.audsid = userenv('sessionid') order by consistent_gets + physical_reads desc -- i.sid; ---- col sid clearKey Features
Section titled “Key Features”- Current Session Focus: Analyzes only the current user’s session I/O
- Comprehensive I/O Metrics: Shows all major I/O statistics
- Cache Efficiency Analysis: Calculates logical to physical read ratios
- Block Change Tracking: Shows data modification activity
- Module Information: Displays the application module context
- Summary Totals: Provides aggregated I/O statistics
- Personal Performance Analysis: Focus on individual session performance
@vmyio.sqlNo parameters required - automatically analyzes the current session.
Required Privileges
Section titled “Required Privileges”SELECT on V$SESSIONSELECT on V$SESS_IOSample Output
Section titled “Sample Output” Session I/O
SID:SERIAL USERNAME OSUSER BLOCK CONSISTENT PHYSICAL LOG/ BLOCK CONSISTENT MODULE GETS GETS READS PHY CHANGES CHANGES------------ ------------ ---------- --------- ------------- --------- ------ --------- ----------- ---------------123:45678 SCOTT jsmith 12,345 9,876,543 45,678 218 23,456 145,789 SQL*Plus
--------- ------------- --------- ------ --------- -----------sum 12,345 9,876,543 45,678 23,456 145,789Key Output Columns
Section titled “Key Output Columns”- SID:SERIAL: Session ID and serial number combination
- USERNAME: Database username
- OSUSER: Operating system username
- BLOCK GETS: Number of blocks read from buffer cache in current mode
- CONSISTENT GETS: Number of blocks read for consistent read operations
- PHYSICAL READS: Number of blocks read from disk
- LOG/PHY: Ratio of logical reads (block gets + consistent gets) to physical reads
- BLOCK CHANGES: Number of blocks modified
- CONSISTENT CHANGES: Number of consistent read blocks changed
- MODULE: Application module name
Understanding I/O Metrics
Section titled “Understanding I/O Metrics”Logical vs Physical Reads
Section titled “Logical vs Physical Reads”Block Gets (Current Mode)
Section titled “Block Gets (Current Mode)”-- Block gets represent:-- Blocks read for modification (current mode)-- Most recent version of blocks-- Typically for INSERT, UPDATE, DELETE operations-- Index maintenance operationsConsistent Gets (Consistent Read)
Section titled “Consistent Gets (Consistent Read)”-- Consistent gets represent:-- Blocks read for query consistency-- Point-in-time consistent data-- Typically for SELECT operations-- Undo-based reconstructed blocksPhysical Reads
Section titled “Physical Reads”-- Physical reads indicate:-- Blocks not found in buffer cache-- Disk I/O operations required-- Cache misses for required data-- Performance impact operationsCache Efficiency Analysis
Section titled “Cache Efficiency Analysis”Logical to Physical Ratio (LOG/PHY)
Section titled “Logical to Physical Ratio (LOG/PHY)”-- Ratio interpretation:-- High ratio (>10): Good cache utilization-- Low ratio (<5): Poor cache efficiency-- Ratio of 1: All reads from disk-- Very high ratio: Excellent cache performanceCache Hit Rate Calculation
Section titled “Cache Hit Rate Calculation”-- Cache hit rate formula:-- Hit Rate = 1 - (Physical Reads / (Block Gets + Consistent Gets))-- High hit rate (>90%): Good performance-- Low hit rate (<80%): Potential tuning neededCommon Use Cases
Section titled “Common Use Cases”-
Personal Performance Analysis
- Analyze your own query performance
- Understand I/O patterns of current work
- Identify inefficient operations
- Support individual query tuning
-
Session Troubleshooting
- Diagnose slow-running operations
- Identify I/O-intensive activities
- Understand cache utilization
- Support performance optimization
-
Query Optimization
- Measure query I/O efficiency
- Compare before/after optimization results
- Validate index usage effectiveness
- Support SQL tuning efforts
-
Application Development
- Understand application I/O characteristics
- Validate development code efficiency
- Support testing and debugging
- Analyze prototype performance
Advanced Analysis
Section titled “Advanced Analysis”I/O Pattern Analysis
Section titled “I/O Pattern Analysis”Read-Heavy vs. Write-Heavy Operations
Section titled “Read-Heavy vs. Write-Heavy Operations”-- Operation type indicators:-- High consistent gets: SELECT-heavy operations-- High block gets: DML-heavy operations-- High block changes: UPDATE/INSERT intensive-- Balanced pattern: Mixed workloadData Access Efficiency
Section titled “Data Access Efficiency”-- Efficiency indicators:-- Low physical reads with high logical reads: Good-- High physical reads: Poor cache utilization-- Very high logical reads: Potential inefficiency-- Optimization opportunities identificationCache Performance Assessment
Section titled “Cache Performance Assessment”Buffer Cache Utilization
Section titled “Buffer Cache Utilization”-- Cache effectiveness factors:-- Data access patterns-- Working set size vs. cache size-- Query selectivity-- Index utilization effectivenessPerformance Optimization Opportunities
Section titled “Performance Optimization Opportunities”-- Optimization areas:-- Query rewriting for better cache utilization-- Index optimization for reduced I/O-- Data access pattern improvement-- Buffer cache sizing considerationsApplication Module Analysis
Section titled “Application Module Analysis”Module-Specific Performance
Section titled “Module-Specific Performance”-- Module context analysis:-- SQL*Plus: Interactive operations-- Application modules: Programmatic access-- Batch processes: Bulk operations-- Tools: Utility and maintenance operationsReal-Time Monitoring Applications
Section titled “Real-Time Monitoring Applications”Session Performance Tracking
Section titled “Session Performance Tracking”Before/After Comparisons
Section titled “Before/After Comparisons”-- Performance comparison workflow:-- 1. Run script before operation-- 2. Execute target SQL or procedure-- 3. Run script again after operation-- 4. Compare I/O metrics for impact assessmentCumulative Analysis
Section titled “Cumulative Analysis”-- Session-level cumulative metrics:-- Total I/O since session start-- Incremental I/O for specific operations-- Performance trend during session-- Resource consumption patternsQuery Tuning Support
Section titled “Query Tuning Support”Baseline Establishment
Section titled “Baseline Establishment”-- Tuning workflow support:-- Establish baseline I/O metrics-- Test optimization changes-- Measure improvement or degradation-- Validate tuning effectivenessIndex Impact Assessment
Section titled “Index Impact Assessment”-- Index optimization validation:-- Measure I/O before index creation-- Execute queries with new indexes-- Compare I/O reduction achieved-- Validate optimization benefitsIntegration with Other Analysis
Section titled “Integration with Other Analysis”Correlation with Wait Events
Section titled “Correlation with Wait Events”I/O Wait Correlation
Section titled “I/O Wait Correlation”-- Combine with wait event analysis:-- Physical reads correlation with I/O waits-- Buffer cache efficiency vs. wait times-- Performance bottleneck identification-- Root cause analysis supportSession Activity Correlation
Section titled “Session Activity Correlation”-- Activity-based analysis:-- SQL execution correlation-- Time-based I/O patterns-- Resource consumption trends-- Performance impact assessmentSQL Statement Analysis
Section titled “SQL Statement Analysis”Statement-Level I/O
Section titled “Statement-Level I/O”-- Correlate with specific SQL:-- Individual query I/O consumption-- Cumulative effect of multiple queries-- Application operation efficiency-- Optimization priority identificationBest Practices
Section titled “Best Practices”Regular Monitoring
Section titled “Regular Monitoring”Session Health Checks
Section titled “Session Health Checks”-- Regular monitoring schedule:-- Before major operations-- After significant changes-- During performance troubleshooting-- As part of tuning methodologyPerformance Baselines
Section titled “Performance Baselines”-- Baseline establishment:-- Normal operation I/O patterns-- Expected efficiency ratios-- Typical cache utilization-- Performance benchmarksOptimization Methodology
Section titled “Optimization Methodology”Systematic Approach
Section titled “Systematic Approach”-- Optimization process:-- Measure current performance-- Implement targeted changes-- Validate improvement-- Document results and lessons learnedImpact Assessment
Section titled “Impact Assessment”-- Change impact evaluation:-- I/O reduction quantification-- Performance improvement measurement-- Resource utilization optimization-- User experience enhancementTroubleshooting Applications
Section titled “Troubleshooting Applications”High I/O Issues
Section titled “High I/O Issues”Excessive Physical Reads
Section titled “Excessive Physical Reads”-- High physical read investigation:-- Query plan analysis for full table scans-- Index usage evaluation-- Buffer cache sizing assessment-- Data access pattern optimizationPoor Cache Utilization
Section titled “Poor Cache Utilization”-- Cache efficiency improvement:-- Query optimization for cache-friendly access-- Index strategy enhancement-- Buffer cache parameter tuning-- Workload pattern analysisPerformance Degradation
Section titled “Performance Degradation”I/O Efficiency Decline
Section titled “I/O Efficiency Decline”-- Performance degradation analysis:-- Compare with historical baselines-- Identify efficiency ratio changes-- Analyze access pattern modifications-- Plan optimization interventionsResource Contention
Section titled “Resource Contention”-- Contention impact assessment:-- I/O subsystem pressure-- Buffer cache competition-- Resource allocation optimization-- System-level tuning considerationsRelated Scripts
Section titled “Related Scripts”- vsessio.sql - All session I/O analysis
- vsession.sql - Session information
- vfile.sql - File I/O statistics
- vio2.sql - System I/O analysis
Development and Testing Support
Section titled “Development and Testing Support”Code Development
Section titled “Code Development”Development Workflow Integration
Section titled “Development Workflow Integration”-- Development process support:-- Baseline I/O measurement-- Code change impact assessment-- Performance regression detection-- Optimization validationTesting Support
Section titled “Testing Support”-- Testing process integration:-- Unit test performance validation-- Load test I/O characteristic analysis-- Performance test baseline establishment-- Regression test performance verificationDebugging Applications
Section titled “Debugging Applications”Performance Issue Diagnosis
Section titled “Performance Issue Diagnosis”-- Debugging workflow:-- Identify high I/O operations-- Analyze inefficient access patterns-- Support root cause identification-- Guide optimization effortsOptimization Validation
Section titled “Optimization Validation”-- Validation process:-- Measure optimization effectiveness-- Quantify performance improvements-- Validate cache utilization enhancement-- Document optimization resultsSummary
Section titled “Summary”This script is essential for:
- Personal Performance Analysis - Understanding your own session’s I/O characteristics and efficiency
- Query Optimization - Supporting individual SQL statement tuning and optimization efforts
- Session Troubleshooting - Diagnosing and resolving session-specific performance issues
- Development Support - Analyzing application code performance and efficiency during development
- Testing and Validation - Measuring and validating performance improvements and optimization effectiveness