Fixes
- Oracle Database · Fix
"ORA-01000: maximum open cursors exceeded": find the sessions holding them
Find which sessions, machines and SQL hold the most open cursors when ORA-01000 hits, from gv$sesstat 'opened cursors current'.
- Oracle Database · Fix
"ORA-01652: unable to extend temp segment": who is using TEMP right now
Find the sessions and SQL using TEMP space when ORA-01652 hits, plus TEMP tablespace size and free space, from v$tempseg_usage and dba_temp_free_space.
Scripts
- Oracle Database · Script
"ORA-01438: value larger than specified precision": the largest value NUMBER(p) accepts
Print the largest value a NUMBER(p) column can store, to check whether a value that hit ORA-01438 really doesn't fit, or to size a new column.
- Oracle Database · Script
"ORA-03297: file contains used data beyond requested RESIZE value": shrink datafiles to the high-water mark
Generate ALTER DATABASE DATAFILE RESIZE statements that shrink each file of a tablespace to its last used extent, so you never ask for a size below the high-water mark.
- Oracle Database · Script
ASM disk group usage that accounts for mirroring (usable_file_mb)
How full each ASM disk group really is, using usable_file_mb so normal and high redundancy groups don't look emptier than they are.
- Oracle Database · Script
Drill into one session: current SQL, wait event and statistics
Given an instance and SID, show a session's full current SQL, what it's waiting on and any statistic by name; plus waits for every session of one app by client_info.
- Oracle Database · Script
Extract PL/SQL source to a file from dba_source
Spool a package, package body, procedure or function from dba_source into a ready-to-run CREATE OR REPLACE script, named owner.name.sql.
- Oracle Database · Script
Find bursts of redo log switches (v$log_history by X-minute window)
Group v$log_history into X-minute windows and list every window with more than N log switches, to find the batch job behind a redo storm.
- Oracle Database · Script
Find SQL that doesn't use bind variables (literal SQL in the shared pool)
Group the shared pool's SQL by text with literals stripped to find statements that differ only in their values, the cause of hard parsing and shared pool churn.
- Oracle Database · Script
Find the sessions and OS processes behind a Data Pump job
Map each running Data Pump job (expdp, impdp) to its database sessions and OS process IDs via dba_datapump_sessions, v$session and v$process.
- Oracle Database · Script
Get the SQL text and execution plan for a SQL_ID (dbms_xplan.display_cursor)
Print the execution plan of a cursor in the shared pool with dbms_xplan.display_cursor, the full SQL text for a SQL_ID, and an explain plan template.
- Oracle Database · Script
List open accounts that have the DBA role
A quick security check: every open database account granted the DBA role directly, from dba_role_privs and dba_users.
- Oracle Database · Script
login.sql: a SQL*Plus prompt that shows user@database
A small login.sql that sets a user@database prompt, timing and time on, unlimited serveroutput and vi as the editor, so you always know where you are.
- Oracle Database · Script
Parallel DML: the slaves of a query coordinator and the undo each uses
For a parallel DML statement, list each PX slave of its query coordinator with its transaction start time and undo blocks used, from v$px_session and v$transaction.
- Oracle Database · Script
Redo log switches per hour, by day (v$log_history)
A day-by-hour grid of redo log switches from v$log_history, plus redo log group sizes, to see when redo peaks and whether the logs are big enough.
- Oracle Database · Script
RMAN backup throughput per hour (v$backup_async_io)
RMAN backup speed per hour over the last 7 days from v$backup_async_io, plus the RMAN sessions running now and what they're waiting on.
- Oracle Database · Script
Tablespace usage against autoextend max size, not just allocated space
Tablespace and datafile usage measured against how far autoextend can still grow each file, so a 95% full tablespace with room to grow isn't a false alarm.
- Oracle Database · Script
Top 10 sessions by I/O right now (v$sesstat)
The ten active sessions with the most logical and physical I/O, with user, OS process, machine, module and how long they've been active.
- Oracle Database · Script
Undo usage by session and transaction (v$transaction)
How much undo each open transaction uses and which session owns it, plus active, unexpired and expired undo extents, for ORA-30036 and long-running DML.
- Oracle Database · Script
Who is blocking whom across RAC instances (gv$lock decoded)
One SQL*Plus script that shows blocked objects, blocker and waiter sessions across every RAC instance, with the SQL each one is running.
- Oracle Database · Script
Who's connected: sessions by service, host and status across RAC (gv$session)
Four gv$session queries for a connection storm or a leaking pool: count by service and instance, by machine pattern, and per host with the SQL each session runs.
New fixes and field notes by email
New KB entries and HASHJOIN Field Notes on running production database fleets. About once a month, no spam.