Session License Limits (vlicense.sql)
What This Script Does
Section titled “What This Script Does”This script provides Oracle license and session limit information by:
- Displaying maximum session limits configured
- Showing current session usage
- Indicating warning thresholds
- Tracking high-water marks for capacity planning
- Reporting user license limits
Script
Section titled “Script”rem vlicense.sqlremttitle 'Sessions Summary'remcol sessions_max heading 'MAX|SESSIONS'col sessions_warning heading 'WARNING|SESSIONS'col sessions_current heading 'CURRENT|SESSIONS'col sessions_highwater heading 'HIGHWATER|SESSIONS'col users_max heading 'MAX|USERS'remselect sessions_max, sessions_warning, sessions_current, sessions_highwater, users_max from v$license;
SQL> @vlicense.sql
Required Privileges
Section titled “Required Privileges”- SELECT on V$LICENSE
Sample Output
Section titled “Sample Output”Sessions Summary
MAX WARNING CURRENT HIGHWATER MAX SESSIONS SESSIONS SESSIONS SESSIONS USERS--------- --------- --------- --------- --------- 472 378 156 245 0
Key Output Columns
Section titled “Key Output Columns”- MAX SESSIONS: Maximum number of concurrent sessions allowed
- WARNING SESSIONS: Warning threshold for session count
- CURRENT SESSIONS: Current number of active sessions
- HIGHWATER SESSIONS: Highest number of sessions reached since startup
- MAX USERS: Maximum named users (0 = unlimited)
Understanding Session Limits
Section titled “Understanding Session Limits”Session Parameters
Section titled “Session Parameters”- SESSIONS: Derived from PROCESSES parameter
- PROCESSES: Maximum number of OS processes
- Calculation: SESSIONS = (1.1 * PROCESSES) + 5
Warning Levels
Section titled “Warning Levels”- Warning Threshold: Usually 80% of maximum sessions
- Critical Level: Approaching maximum sessions
- Capacity Planning: Use highwater mark for planning
Common Use Cases
Section titled “Common Use Cases”-
Capacity Monitoring
- Monitor current session usage
- Track peak session counts
- Plan for growth
-
License Compliance
- Verify license limits
- Monitor user connections
- Ensure compliance with Oracle licensing
-
Performance Analysis
- Correlate session counts with performance
- Identify peak usage periods
- Plan connection pooling
Session Management
Section titled “Session Management”Check Current Sessions
Section titled “Check Current Sessions”-- Count active sessions by typeSELECT status, type, COUNT(*) session_countFROM v$sessionGROUP BY status, typeORDER BY status, type;
-- Find user sessionsSELECT username, COUNT(*) session_countFROM v$sessionWHERE username IS NOT NULLGROUP BY usernameORDER BY session_count DESC;
Session Parameters
Section titled “Session Parameters”-- Check related parametersSELECT name, value, descriptionFROM v$parameterWHERE name IN ('processes','sessions','license_max_sessions', 'license_sessions_warning','license_max_users')ORDER BY name;
Warning Scenarios
Section titled “Warning Scenarios”Approaching Limits
Section titled “Approaching Limits”- Current > 80% of Max: Monitor closely
- Current > 90% of Max: Consider action
- Current = Max: New connections will fail
High Water Analysis
Section titled “High Water Analysis”- Growing Trend: May need parameter increase
- Stable Pattern: Normal operational range
- Spikes: Investigate application behavior
Tuning Recommendations
Section titled “Tuning Recommendations”Increase Session Limits
Section titled “Increase Session Limits”-- Increase PROCESSES (requires restart)ALTER SYSTEM SET processes=600 SCOPE=SPFILE;-- SESSIONS will be calculated automatically
-- Check calculated SESSIONS valueSELECT name, valueFROM v$parameterWHERE name IN ('processes','sessions');
Connection Management
Section titled “Connection Management”-
Connection Pooling
- Implement application connection pools
- Reuse connections efficiently
- Configure appropriate pool sizes
-
Session Cleanup
- Kill idle sessions if necessary
- Implement connection timeouts
- Monitor long-running sessions
License Considerations
Section titled “License Considerations”Named User Licensing
Section titled “Named User Licensing”- MAX USERS: Set based on license agreement
- Concurrent Sessions: May exceed named users
- Compliance: Ensure proper licensing
Processor Licensing
Section titled “Processor Licensing”- Unlimited Users: MAX USERS = 0
- Session Limits: Based on hardware capacity
- No User Restrictions: Focus on performance
Monitoring Alerts
Section titled “Monitoring Alerts”Session Threshold Alerts
Section titled “Session Threshold Alerts”-- Check if approaching limitsSELECT CASE WHEN sessions_current > sessions_max * 0.9 THEN 'CRITICAL' WHEN sessions_current > sessions_warning THEN 'WARNING' ELSE 'OK' END AS status, sessions_current, sessions_max, ROUND(sessions_current/sessions_max*100,1) AS pct_usedFROM v$license;
Historical Tracking
Section titled “Historical Tracking”-- Create monitoring tableCREATE TABLE session_usage_history ( check_time DATE, current_sessions NUMBER, max_sessions NUMBER, highwater_sessions NUMBER);
-- Insert current valuesINSERT INTO session_usage_historySELECT SYSDATE, sessions_current, sessions_max, sessions_highwaterFROM v$license;
Troubleshooting
Section titled “Troubleshooting”ORA-00020: Maximum Number of Processes Exceeded
Section titled “ORA-00020: Maximum Number of Processes Exceeded”- Check current process usage
- Increase PROCESSES parameter
- Restart database instance
High Session Usage
Section titled “High Session Usage”-
Identify Heavy Users
- Find users with many sessions
- Check for connection leaks
- Review application design
-
Session Analysis
- Check for idle sessions
- Monitor session duration
- Implement session timeouts