Monitor active Teradata sessions using real-time resources, view SQL execution details, identify blocking issues, and optionally take control actions
Monitor and analyze active sessions in the Teradata database system to identify performance issues, blocking problems, and resource consumption patterns using real-time MCP resources and tools.
This skill now leverages real-time MCP resources for faster monitoring!
With tdwm-mcp v1.5.0, this skill provides:
Session Monitoring:
list_sessions - List all active user sessions with detailsshow_session_sql_text - View full SQL text for specific sessionshow_session_sql_steps - View execution steps for session querymonitor_session_query_band - View query band settings for sessionsidentify_blocking - Identify sessions blocking other sessionsControl Actions (Optional):
abort_sessions_user - Terminate all sessions for a specific userRelated Monitoring:
show_tdwm_summary - View workload distribution (context for sessions)show_query_log - Historical query analysisReal-Time Session Data:
tdwm://system/sessions - Real-time snapshot of all active sessionstdwm://system/summary - Workload distribution showing session contexttdwm://system/workloads - Active workloads (to understand session classification)Query Analysis:
tdwm://system/delayed-queries - Sessions waiting in delay queuestdwm://system/throttle-statistics - Throttle impact on sessionsReference:
tdwm://reference/session-states - Explanation of session statestdwm://reference/blocking-types - Types of blocking scenariosGet Real-Time Session Overview
tdwm://system/sessionsUnderstand Workload Context
tdwm://system/summaryList Active Sessions
list_sessions for detailed, sortable session dataExamine Session SQL
show_session_sql_text to see full query textshow_session_sql_steps to see execution stepsCheck for Blocking
identify_blocking to find lock contentionReview Query Bands
monitor_session_query_band to see session tagsCorrelate Session Data
tdwm://system/throttle-statistics)Provide Recommendations
abort_sessions_userScenario: "Show me what's currently running on the database"
Action (Resource-First Approach):
1. Read real-time sessions:
tdwm://system/sessions
→ Instant snapshot: 47 active sessions
2. Analyze resource data:
- 23 sessions in ETL workload (expected for this time)
- 15 sessions in INTERACTIVE workload
- 9 sessions in DEFAULT workload
- Most sessions <5 minutes runtime (normal)
- 2 sessions running >30 minutes (investigate)
3. Get workload context:
tdwm://system/summary
→ ETL workload using 60% of resources
→ Interactive workload using 30%
→ System healthy, no overload
4. Report:
"47 active sessions, system healthy. ETL workload dominant (expected).
2 long-running sessions (ID 1234, 5678) worth monitoring."
Result: Complete overview in seconds without running any queries
Scenario: "What is user john_smith doing right now?"
Action (Resource + Tool Approach):
1. Check resource first:
tdwm://system/sessions
→ Filter for user='john_smith'
→ Found 3 active sessions: 1245, 1246, 1247
2. Get detailed session data:
list_sessions()
→ Filter output for john_smith
→ Session 1245: Running 45 minutes, high CPU
→ Session 1246: Running 2 minutes, normal
→ Session 1247: Idle, 0 CPU
3. Examine long-running session 1245:
show_session_sql_text(session_id=1245)
→ Query: Large aggregation on fact table
→ No obvious optimization issues
show_session_sql_steps(session_id=1245)
→ Currently in step 5 of 8
→ Doing JOIN operation
→ No blocking detected
4. Check query band:
monitor_session_query_band()
→ Filter for session 1245
→ Query band: APP=ANALYTICS_TOOL, USER=john_smith
→ Classified in ANALYTICS workload (correct)
5. Report:
"john_smith has 3 sessions:
- Session 1245: Long-running analytics query (45 min), progressing normally
- Session 1246: Recent query, completing soon
- Session 1247: Idle connection
No issues detected. Long query is expected for analytics workload."
Result: Complete user activity profile with context
Scenario: "Some queries seem stuck, check for blocking"
Action (Blocking Analysis):
1. Quick resource check:
tdwm://system/sessions
→ 12 sessions in "blocked" state
→ Multiple sessions waiting on locks
2. Identify blocking chains:
identify_blocking()
→ Blocking detected!
→ Session 2001 (user: etl_batch) is blocking 8 sessions
→ Session 2050 (user: report_user) is blocking 4 sessions
3. Analyze blocking session 2001:
show_session_sql_text(session_id=2001)
→ UPDATE statement on CUSTOMER table
→ Has been running for 90 minutes
→ Holding exclusive table lock
list_sessions()
→ Filter for session 2001
→ Started at 02:00 AM (ETL window)
→ Should have completed by now
4. Check blocked sessions:
list_sessions()
→ Filter for blocked sessions
→ All trying to SELECT from CUSTOMER table
→ Waiting for lock release
→ Users complaining about reports not loading
5. Analyze second blocker (session 2050):
show_session_sql_text(session_id=2050)
→ Long-running report query
→ Holding shared lock, blocking UPDATE attempts
6. Review reference:
tdwm://reference/blocking-types
→ Scenario: ETL update blocking reports = Type 1 blocking
→ Recommendation: Complete ETL or abort if stuck
7. Report:
"BLOCKING DETECTED - 12 sessions blocked:
Primary blocker: Session 2001 (etl_batch)
- Running 90 minutes (abnormally long)
- UPDATE on CUSTOMER table
- Blocking 8 report sessions
- RECOMMENDATION: Check if ETL is stuck, may need to abort
Secondary blocker: Session 2050 (report_user)
- Long-running report (60 min)
- Blocking 4 UPDATE attempts
- RECOMMENDATION: Let complete or optimize query
IMMEDIATE ACTION NEEDED for Session 2001"
Result: Clear identification of blocking issues with recommendations
Scenario: "User adhoc_user01 is running runaway queries, kill all their sessions"
Action (Control Action):
1. Verify problem first:
tdwm://system/sessions
→ User adhoc_user01 has 15 active sessions
→ All running identical query
→ System CPU at 95% (critical)
2. Get detailed view:
list_sessions()
→ Filter for adhoc_user01
→ 15 sessions, each using 6% CPU
→ Total: 90% of system CPU
→ All started within 5 minutes (query blast)
3. Check query:
show_session_sql_text(session_id=3001) # Pick one session
→ SELECT with CROSS JOIN (Cartesian product!)
→ Missing WHERE clause
→ Generating billions of rows
4. Confirm termination decision:
- Runaway query confirmed
- No business justification for Cartesian product
- System critically overloaded
- User needs to be stopped
5. Execute termination:
abort_sessions_user(username="adhoc_user01")
→ Terminating all 15 sessions for adhoc_user01
→ Result: "15 sessions terminated"
6. Monitor recovery:
tdwm://system/summary
→ Wait 30 seconds
→ CPU dropping from 95% to 45%
→ System recovering
7. Document incident:
"Emergency termination of adhoc_user01 sessions at 14:23:
- 15 runaway queries with Cartesian product
- Consuming 90% of system CPU
- Missing WHERE clause in query
- System returned to normal after termination
- User notified to fix query before resubmitting"
Result: System stabilized, incident documented
Scenario: Daily morning check of overnight session activity
Action (Comprehensive Audit):
1. Get high-level overview:
tdwm://system/summary
→ 34 active sessions (normal for 8 AM)
→ ETL workload: 12 sessions
→ Interactive: 18 sessions
→ Ad-hoc: 4 sessions
2. Check real-time sessions:
tdwm://system/sessions
→ No sessions running >2 hours (good)
→ No blocked sessions
→ Resource usage balanced
3. Review delayed queries:
tdwm://system/delayed-queries
→ 3 queries in delay queue (acceptable)
→ All from ad-hoc workload (expected throttling)
4. Check throttle statistics:
tdwm://system/throttle-statistics
→ ETL throttle: 0 delayed (nighttime processing complete)
→ Ad-hoc throttle: 3 delayed (working as designed)
→ Interactive throttle: 0 delayed (good performance)
5. List all sessions for record:
list_sessions()
→ Full session inventory captured
→ No anomalies detected
6. Check for any blocking:
identify_blocking()
→ No blocking detected
7. Report:
"Morning session audit - 8:00 AM:
✅ 34 active sessions (normal)
✅ No blocking issues
✅ No long-running sessions (all <2 hours)
✅ Throttles working as expected
✅ System healthy
Overnight ETL completed successfully.
Interactive users beginning morning queries.
No issues requiring attention."
Result: Clean bill of health, documented baseline
tdwm://system/sessions)tdwm://reference/session-states for state meanings