SqlBLT

SqlBLT Portal - the Plans report

SqlBLT is a free, open source toolset for SQL Server which logs Blocked queries, Long running queries and Top blockers, along with their query plans and system performance metrics.

SqlBLT also de-parameterizes, aggregates and archives logged data on a configurable schedule.

The SqlBLT Portal app and API reveal sources of blocking and long running queries to humans and AI agents.

SQL Server 2016 and later versions are supported, also Azure SQL Database, Azure SQL Managed Instance and AWS RDS.

SqlBLT is released under the MIT licence. Its scripts, source code, documents and releases are published on GitHub:

Every 10 seconds (configurable), SqlBLT logs the query requests that are:

  • Blocked by another request.
  • Long running, and not involved in blocking.
  • Top blockers, the head of a blocking chain.

SqlBLT logs what each request waits for and for how long, with its statement text and query plan, CPU utilisation, reads, writes and wait time.

Statements and query plans are de-parameterised into templates, so that requests aggregate by template rather than by unique text.

Performance metrics are captured at the same interval for correlation with the BLT data: wait statistics, SQL Server performance counters, CPU, memory, schedulers, sessions, tempdb, and file IO per database.

SQL Server's missing index recommendations and the query optimizer's plan warnings are logged with the requests.

The logged samples are aggregated by second, minute, hour and day. Retention is configurable for the samples and for each aggregate.

SqlBLT components

  • SqlBLT database: holds the SqlBLT schema, with captured sessions, aggregates (Agg_*), metrics (metric_*), and the SqlBLTPortal schema with the read-only report procedures. We recommend a dedicated database with a Memory-Optimized Filegroup for optimal performance, but SqlBLT can also run comfortably within another user database. It creates its own private schemas and should not interfere with other activity within a shared database.
  • SQL Server Agent jobs: SqlBLT_Collector and SqlBLT_Metrics sample the instance every 10 seconds; SqlBLT_Aggregate aggregates the data every 10 minutes and archives it once a day. You can reconfigure schedules if you prefer more or less frequent collection but we recommend 10 second intervals as suitable, even on busy databases.
  • SqlBLT API: the operations under api/v1/ through which SqlBLT data is read, described for any program in api/v1/openapi.json (OpenAPI 3.1). It runs inside SqlBLTPortal.exe, connects to SQL Server as the caller's Windows account, as a SQL login the caller supplies, or as the server's service account, and executes only the report procedures. SQL Server authenticates every connection, and a reader needs membership of SqlBLT_Reader.
  • SqlBLT Portal: SqlBLTPortal.exe, run as a desktop app on the user's computer, or on a server as a Windows service or an IIS site for browser access, optionally published with sign-in at the organisation's identity provider (OpenID Connect). Its page reads every report through the API.
  • Your AI agent, or any program: calls the API with its address and its description, and a credential: the key of the desktop app on the user's computer, its Windows account on a server with Windows authentication, or an access token of the identity provider on a published server.

The SqlBLT Portal is one self-contained file for Windows, which needs no installation and no runtime. It runs as a desktop app, as a Windows service, or as a web site under IIS.

The TopX report shows the top statements by wait time, with the metrics below.

Choose Blocked, Long Running or Top Blockers, and filter by Database, Application, Host, Login, Wait Type or Resource, for a specific or relative time frame.

SqlBLT Portal - the TopX report

The Timeline report shows the top blockers as swim lanes, one expandable lane per top blocker, with the metrics and the statement and query plan of the selected request below.

Drag over the time axis to zoom the whole report to one blocking event: the request's timeline, its statement and its plan.

SqlBLT Portal - the Timeline report

The Plans report shows how the query plans of a statement performed over the time range: one circle for each of its requests, at the time the request ran, coloured by the query plan it used.

A green leaf marks a statement or a request for which SQL Server recommends a missing index. An orange exclamation mark marks a statement or a request whose query plan carries a warning of the query optimizer.

The Portal has a light theme and a dark theme. The Plans report is shown here in the light theme.

SqlBLT Portal - the Plans report, light theme

The SqlBLT API is the set of operations under api/v1/ through which SqlBLT data is read. It runs inside SqlBLTPortal.exe, and the Portal's page reads every report through it.

Any other program, a script or an AI agent, calls the same operations with the same results.

Its description, api/v1/openapi.json (OpenAPI 3.1), states how to call it, what the data answers, and every operation, parameter and column.

The Portal and its API read the database through read-only report procedures and never change it.

  • Create a database named SqlBLT, or choose an existing database. A Memory-Optimized filegroup is recommended: it is used only by the natively compiled functions which parse statement text and query plans. Data is not stored In-Memory.
  • Download the script SqlBLT-install.sql and run it in that database. An uninstall script is also available.
  • Optionally download SqlBLTPortal.exe, launch it and connect to the SqlBLT database to explore BLT data.
  • Optionally connect your AI agent to the SqlBLT API.

The files of every release are on its Release page on GitHub.

The SqlBLT Guide describes what SqlBLT logs, its installation, the Portal and its API, its permissions and settings.

The SqlBLT Database document describes every table, column, view, setting and metric of the database.

The SqlBLT Deployment document describes the deployment options of the Portal and its API, the authentication of users and programs, the set-up at identity providers, security, and every setting.