Why a query is slow

Read a query the way
the database does

Paste a SELECT statement and, if you know them, the columns that have an index. The page looks for the patterns that make queries slow, explains in plain words why each one costs and what to try, and ranks them so you know where to start.

$9.99a month · everything on Caveat

Cancel anytime. How plans and refunds work

Included with Caveat Plus ($9.99 a month or $99.90 a year), Caveat Family (up to 5 people, $14.99 a month) and Caveat Teams (25 people, $199 a month). Anything you bought before stays yours.

Enter your figures and read the result

Paste a SELECT. The worked example is an invented query over student and enrollment tables with several common problems.

Loading SQL Query Performance Explainer. If nothing appears, turn on JavaScript.

What you get

Teaching · For TeachersIncluded with Caveat Plus

What you finish with
A worked-out result for your own entry (a headline figure, tiles, tables and a drawing where one helps), as a printout, a spreadsheet (.csv) or a saved file.
Who it is for
Students learning SQL, teachers of database classes, and school staff who write reports against a student information system.
Format
Browser tool for a phone, tablet or computer: type or paste, the result updates as you type. Print, spreadsheet (.csv), save to a file and open it again.
Access
Included with Caveat Plus ($9.99 a month) and Caveat Teams. It opens once you are signed in, on every device. Anything you bought before stays yours.
Where it lives
The For Teachers space in Caveat Teaching.
Support
Questions about access, an order or a correction: team@caveatacademic.com.

How to use it

  1. Load the worked example to see how it reads, or start with your own entry.
  2. Type or paste into the fields; the result updates as you type.
  3. Read the headline, the tiles and the tables.
  4. Try a second case from the buttons above the fields.
  5. Print the result, download a spreadsheet or save the entry to a file.

Explain a query

How it works

The worked example from a pasted query to a ranked list of things to look at.

Sargable conditions

A condition is sargable when the database can use an index to find matching rows. A bare column compared to a value usually is. The same column wrapped in a function, or compared with a pattern that starts with a wildcard, usually is not.

Measure before changing

Whether a change helps depends on how big the tables are and what indexes exist. Run EXPLAIN on the original, change one thing, and run it again.

Sources

  1. Winand, M. (2012). SQL Performance Explained. Markus Winand. Also available at use-the-index-luke.com.
  2. PostgreSQL Global Development Group. PostgreSQL Documentation: Using EXPLAIN, postgresql.org/docs.
  3. Silberschatz, A., Korth, H. F., & Sudarshan, S. Database System Concepts (7th ed.), McGraw-Hill, chapter on query optimization.

The worked examples are invented for illustration. What you type is saved only in this browser and is never sent to Caveat. Support: team@caveatacademic.com.

Written with AI, then checked before it is published. How we checkFound a mistake? Report it and we fix it, or refund you.Cancel anytime.