Rerun

Speed Up Slow SQL Queries

Find why a query or database is slow and get the fix as ready-to-run SQL, with its expected gain, its cost and its rollback, plus a weekly health check.

Speed Up Slow SQL Queries agent board

About

Paste a slow query and its schema, or connect your database read-only, and get a diagnosis grounded in the query plan with the exact SQL to fix it.

What it does

  • Diagnoses slow queries from the plan and statistics, rewrites them and proposes the right indexes, each with its gain, cost and rollback
  • Writes and explains SQL for your engine, from a question and your schema
  • Reviews schemas, indexes and migrations before they reach production
  • Creates databases, users and roles with least privilege, and sets up scheduled queries and backups
  • Runs a weekly health check: growth, slowest queries, unused indexes, connections, backup age

What you need

  • Nothing to start: paste a query, its schema and the EXPLAIN output
  • A read-only connection to your database for the real diagnosis: the catalogue app of your host (Supabase, Neon, BigQuery and others) or a read-only connection string stored as a secret

How setup works

You paste a slow query and get the diagnosis and the fix in the first minutes. It then learns your engine, host and environments, connects read-only, lists your slowest queries and offers the weekly health check.

What stays in your hands

  • Every statement that writes, alters, drops or grants is shown first and runs only after your go-ahead
  • Destructive operations need a confirmation naming the target, and a fresh backup

Coworkers in this template

Database Admin

Finds why your database is slow and gives the exact SQL to fix it, and keeps accounts, scheduled jobs and backups in order.

Skills · 5

Back up the database

Use when asked to set up, run, check or restore a database backup or export.

Schedule the queries

Use when asked to run a SQL query or job at set times or intervals, or to fix a scheduled query that failed.

Set up databases and access

Use when asked to create or drop a database, a user or a role, or to change who can read or write what.

Speed up slow queries

Use when a query, a database or a page backed by it is slow, to review a schema, indexes or a migration, and on the weekly health check.

+1 more

Scheduled tasks · 1

Weekly database health check

At 08:00 AM, only on Monday

Frequently asked questions

Which databases does it work with?

PostgreSQL, MySQL and MariaDB, SQL Server, SQLite and warehouses such as BigQuery. It writes SQL for your engine and version and uses your host's native tools when they exist.

Does it need access to my production database?

Not to start: paste a query, its schema and the EXPLAIN output. For the real diagnosis it uses a read-only connection, through your host's app in the Rerun catalogue or a read-only connection string you store as a secret.

Will it change my database on its own?

No. Anything that writes, alters, drops or grants is shown with its effect and rollback, and runs only after your go-ahead. Destructive operations also need a fresh backup.

How does it decide which index to add?

From the query plan, the row estimates and the statistics. It prefers the smallest change, checks overlaps with existing indexes and states the write and disk cost of each one.

Can it set up backups and scheduled queries?

Yes. It prefers your host's managed backups and scheduled queries, writes the script when there are none, and asks for a restore test on a copy so you know the backup works.

How much does it cost to run?

The template is free. Runs use your Rerun credit.

2,000+ businesses run on Rerun

Hire Coworkers on the ChatGPTplan you already pay for.

  • 1. Plug in your subscription
  • 2. Set up your Coworkers
  • 3. Run your business with Coworkers