Help home > Server Monitor

Server Monitor

See the sessions connected to the database, the current locks, the SQL that takes the most time, and index fragmentation. You can also cancel stuck SQL and kill sessions.

What you can do

TaskHow to open
Open the monitor tabRight-click a connection name in the tree and choose "Server Monitor (Sessions, Locks, Expensive SQL)", or choose "Tools" → "Server Monitor (Sessions, Locks, Expensive SQL)" from the menu (uses the connection of the current tab)
Supported databasesSQL Server (including LocalDB), PostgreSQL, MySQL / MariaDB and Oracle. SQLite and SQL Server Compact are not supported

Getting started: finding the cause of slowness (3 steps)

  1. Check the locks

    In Locks, look for rows whose Status is "WAIT" or "Waiting". "Blocked by" is the session that is making them wait (see Locks).
  2. Check the blocking session

    In Sessions, check that session's SQL and elapsed time (see Sessions).
  3. Fix the heavy SQL

    In Expensive Queries, pick a query with a long total time, then right-click and choose "View Estimated Execution Plan" to check whether indexes are used (see Expensive queries).

Sessions

Lists the sessions connected to the database, with running sessions first. The row with ○ in "Self" is this Musubi SQL connection.

ColumnContents
IDThe session number ("SID,SERIAL#" in Oracle). Used to cancel or kill
Status, WaitWhether it is running and what it is waiting for (as reported by the database)
Blocked byThe ID of the session this session is waiting for
Elapsed ms / Elapsed sTime since the current SQL started (seconds in MySQL and Oracle)
SQLThe running (or most recently run) SQL

Turn on "Hide idle sessions" to hide sessions that aren't doing anything.

Locks

Lists the locks held by sessions and the sessions waiting for locks, with waiting rows first. While the session shown in "Blocked by" keeps holding its lock, other sessions can't proceed.

A common causeA session in manual commit mode that updated data and never committed or rolled back. Check that session's Program and User in the session list.

Expensive queries

Shows the top 100 queries by total execution time, from the execution statistics the server records. Executions, average time and average reads tell you which SQL is worth fixing first.

DatabaseSource
SQL Serversys.dm_exec_query_stats (statistics since the server last restarted)
PostgreSQLThe pg_stat_statements extension
MySQLperformance_schema.events_statements_summary_by_digest (literal values are normalized to ?)
OracleV$SQLAREA (excluding SYS and SYSTEM)

Right-click a row for "Open SQL in SQL Tab", "View Estimated Execution Plan" and "Copy SQL". In PostgreSQL and MySQL, values appear as $1 or ?, so replace them with real values before viewing the execution plan.

Index fragmentation

Checks how fragmented the indexes in the current database are and lists the ones that likely need a rebuild first. Because this can take a while on a large database, switching to this view does not run it. Click ▶ Inspect (auto refresh does not apply).

DatabaseHow it is measured"Recommendation" guideline
SQL ServerFragmentation and page count from sys.dm_db_index_physical_stats (LIMITED)Indexes under 1,000 pages are ignored. Reorganize at 5–30%, rebuild at 30% or more
PostgreSQLLeaf density and fragmentation from pgstatindex in the pgstattuple extension (B-tree only). It reads every index, which adds loadRebuild when leaf density is below 70% or fragmentation is 30% or more
MySQLPer-index values are not available, so this shows the share of free space (DATA_FREE) per table from information_schema.TABLES. The values are cached statistics; run ANALYZE TABLE first for fresh valuesOPTIMIZE TABLE at 20% or more
OracleFragmentation cannot be measured without locking the table, so this estimates it from the statistics in ALL_INDEXES (height/BLEVEL and leaf blocks, current schema)A height of 4 or more is a rebuild candidate. Gather statistics first when they are missing or stale

Select rows and right-click to open the rebuild, reorganize, or statistics SQL in a SQL tab (nothing is run immediately). With several rows selected, all statements go into one SQL tab. Review them before running.

Rebuilding takes locksSQL Server REBUILD, PostgreSQL REINDEX (without CONCURRENTLY), and MySQL OPTIMIZE TABLE can block updates to the table while they run. On production systems, run them during quiet hours.

Canceling SQL and killing sessions

Right-click a row in Sessions or Locks. Both actions ask for confirmation first. They aren't available for your own connection or on read-only connections.

MenuSQL that runs
Cancel Running SQLPostgreSQL pg_cancel_backend, MySQL KILL QUERY, Oracle ALTER SYSTEM CANCEL SQL (not available in SQL Server)
Kill SessionSQL Server KILL, PostgreSQL pg_terminate_backend, MySQL KILL, Oracle ALTER SYSTEM KILL SESSION
Killing a sessionUncommitted changes in that session are rolled back. You are disconnecting another person's or application's connection, so in production always confirm whose session it is first.

Required permissions and settings

DatabaseRequirements
SQL ServerThe VIEW SERVER STATE permission. Killing sessions requires ALTER ANY CONNECTION. Index fragmentation requires VIEW DATABASE STATE
PostgreSQLThe pg_read_all_stats role to see other users' SQL. Expensive queries require the pg_stat_statements extension (add it to shared_preload_libraries, restart, then run CREATE EXTENSION pg_stat_statements). Index fragmentation requires the pgstattuple extension (CREATE EXTENSION pgstattuple) and, for non-superusers, the pg_stat_scan_tables role
MySQLThe PROCESS privilege to see other users' sessions. Locks and expensive queries require read access to performance_schema (locks show more detail on 8.0 and later)
OracleRead access to V$SESSION, V$LOCKED_OBJECT and V$SQLAREA (for example, SELECT_CATALOG_ROLE). Killing sessions requires the ALTER SYSTEM privilege

FAQ

An error appears and the list is empty

A permission or a required setting is missing. What you need is shown below the error (see Required permissions and settings).

I only see my own session

You don't have permission to see other users' sessions. Ask your database administrator to grant it.

The list doesn't change

The lists are reloaded when you open the tab and when you click ⟳ Refresh. Choose an "Auto refresh" interval to reload periodically while the tab is visible.

▲ Back to top

← Musubi SQL website (download)