DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Last call! Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Cookies Revisited: A Networking Solution for Third-Party Cookies
  • Fixing Common Oracle Database Problems
  • How To Replicate Oracle Data to BigQuery With Google Cloud Datastream
  • Lessons from Migrating an Oracle Database to AWS RDS

Trending

  • Apache Doris vs Elasticsearch: An In-Depth Comparative Analysis
  • My LLM Journey as a Software Engineer Exploring a New Domain
  • Unlocking the Benefits of a Private API in AWS API Gateway
  • Understanding and Mitigating IP Spoofing Attacks
  1. DZone
  2. Data Engineering
  3. Databases
  4. How to Efficiently Manage Inactive (IDLE) Oracle Database Sessions

How to Efficiently Manage Inactive (IDLE) Oracle Database Sessions

Learn how to manage inactive Oracle sessions using DCD, IDLE_TIME, and Resource Manager to optimize overall database performance and prevent resource issues.

By 
arvind toorpu user avatar
arvind toorpu
DZone Core CORE ·
Nov. 18, 24 · Tutorial
Likes (1)
Comment
Save
Tweet
Share
2.2K Views

Join the DZone community and get the full member experience.

Join For Free

In busy database environments, inactive or dead connections can accumulate, consuming resources and potentially causing performance issues. This article explores how to manage inactive Oracle sessions using Dead Connection Detection (DCD) and resource parameters like IDLE_TIME, to keep database performance optimal.

Understanding Inactive Sessions

Inactive sessions typically arise from applications or systems that fail to close connections properly. These sessions might be due to users closing their devices without logging out or network disruptions. Over time, unmanaged idle connections can lead to issues, including resource exhaustion.

Detecting and Handling Dead Connections With SQLNET.EXPIRE_TIME

Oracle’s Dead Connection Detection (DCD) feature helps identify inactive connections between the client and server. Set in the sqlnet.ora configuration file, SQLNET.EXPIRE_TIME specifies a time interval (in minutes) to send a probe to check if connections are still active.

  • Configuration: Add SQLNET.EXPIRE_TIME = [minutes] to sqlnet.ora.
  • Functionality: If a connection is inactive, DCD flags it, allowing the database’s Process Monitor (PMON) to release database resources linked to that session.

Benefits: DCD is effective for connections terminated due to network or client issues, freeing server-side resources.

Limitations: It does not work for bequeathed connections and may slightly impact network performance due to additional traffic.

Using IDLE_TIME Profiles for Idle Connections

Oracle provides the IDLE_TIME parameter within user profiles to manage idle sessions, setting the maximum duration of inactivity allowed per session.

1. Enable Resource LimitsFirst, and ensure RESOURCE_LIMIT is set to TRUE.

MariaDB SQL
 
ALTER SYSTEM SET RESOURCE_LIMIT=TRUE SCOPE=BOTH;


2. Set the IDLE_TIME. Apply an idle time limit in minutes to relevant profiles.

SQL
 
ALTER PROFILE at_profile LIMIT IDLE_TIME 30;


SQL
 
Setting IDLE_TIME IN PROFILE PARAMETER

1. CHECK RESOURCE PARAMETER VALUE

SQL> show parameter resource_limit;
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
resource_limit                       boolean     FALSE


2. UPDATE THE RESOURCE PARAMETER TO TRUE

SQL> alter system set resource_limit=TRUE scope=both sid='*';
System altered.


3. CHECK IDLE_TIME VALUE FOR DEFAULT OR OTHER PROFILE

SQL> SELECT PP.PROFILE, PP.RESOURCE_NAME, PP.LIMIT FROM DBA_PROFILES PP WHERE PROFILE='DEFAULT' AND RESOURCE_NAME IN ('IDLE_TIME');
PROFILE        RESOURCE_NAME        LIMIT
-------        -------------        -----
DEFAULT        IDLE_TIME        UNLIMITED



4. CHANGE THE IDLE_TIME TO DESIRED VALUE FOR DEFAULT OR OTHER PROFILE

SQL> ALTER PROFILE DEFAULT LIMIT IDLE_TIME 30;
Profile altered.


5. RE-CHECK IDLE_TIME VALUE FOR DEFAULT OR OTHER PROFILE

SQL> SELECT PP.PROFILE, PP.RESOURCE_NAME, PP.LIMIT FROM DBA_PROFILES PP WHERE PROFILE='DEFAULT' AND RESOURCE_NAME IN ('IDLE_TIME');

PROFILE        RESOURCE_NAME        LIMIT
-------        -------------        -----
DEFAULT        IDLE_TIME            30


3. Monitor the idle session. Once the IDLE_TIME When the threshold is reached, PMON marks the session as "sniped." The session will remain visible in V$SESSION until it attempts a new operation, at which point Oracle cleans it up.

Example: Suppose a user at_user is assigned to profile at_profile, which has an idle time limit of 30 minutes. If at_user the session is inactive beyond this limit, Oracle will mark it as "sniped" and clean up when the user attempts a new action.

Note: It’s best to create custom profiles for users who require resource limits instead of altering default settings.

Leveraging Resource Manager for Advanced Control

Oracle’s Resource Manager provides further control over managing inactive sessions. By configuring a Resource Manager plan, you can specify the MAX_IDLE_TIME for sessions, which will automatically kill sessions exceeding the idle threshold.

For more detailed implementation, refer to Oracle documentation or trusted resources. Resource Manager is suitable for environments where detailed control over session management is necessary.

Best Practices for Cleaning Inactive Sessions

To maintain optimal database performance, consider using profiles to combine DCD with resource limits. This dual approach targets both idle and dead connections:

  • DCD handles dead connections by removing terminated sessions.
  • Resource limits clean-up sessions based on idle time, effectively managing active but unused connections.

Caution: While DCD and Resource Manager can manage many inactive sessions, they won’t eliminate all OS-level processes. Occasionally, manual cleanup of OS processes may still be necessary to free system resources completely.

Summary

Automating the cleanup of inactive sessions in the Oracle Database is vital for maintaining resource efficiency and avoiding performance issues. By leveraging DCD, idle time settings, and Resource Manager, DBAs can ensure their databases remain responsive, even under heavy load. Regularly monitor inactive sessions and apply best practices to keep your database environment streamlined and resource-efficient.

Oracle Database Session (web analytics)

Opinions expressed by DZone contributors are their own.

Related

  • Cookies Revisited: A Networking Solution for Third-Party Cookies
  • Fixing Common Oracle Database Problems
  • How To Replicate Oracle Data to BigQuery With Google Cloud Datastream
  • Lessons from Migrating an Oracle Database to AWS RDS

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!