Data

Find the most expensive queries every month

Once a month, Merlin lists your costliest warehouse queries and dbt models in #data. Each one comes with a way to make it cheaper.

@Merlin every month on the 1st at 09:00, read last month's query history in the warehouse with read-only access and find the ten queries and dbt models that cost the most. Post each here with its cost, how often it ran, what runs it and one concrete way to make it cheaper. Don't change any warehouse setting or model: suggest only.

#data
Get started for free
  1. Starts whenA monthly schedule runs on the 1st at 09:00 and posts to #data
  2. Merlin worksClaude Code or Codex reads last month's query history in Snowflake or Databricks and matches the costly queries to dbt models
  3. You getThe ten costliest queries and models with their cost and one way to make each cheaper

Tools

  • Slack
  • Snowflake
  • Databricks
  • dbt

Capabilities

  • Automations
  • Integrations
  • Your agent's MCP

How it works

From last month's query history to the ten costliest queries and a fix for each.

A monthly schedule starts a run on the 1st at 09:00 and posts to #data.

/AcmeTeam/Automations/Most expensive queriesFeedback?L

Overview

Agents

Skills

Memory

Automations

Integrations

Settings

Most expensive queries

Pause
StatusActive
CreatorL Leo You
ScopeWorkspace
Last runOct 1, 2026, 9:00 AM

DetailsRun history

Trigger

When Merlin runs it.

RuleHow often Merlin runs it.Monthly
Day of monthShort months use their final day.1
TimeNext run Nov 1, 2026, 9:00 AM.09:00

Run

What Merlin does each time, where it runs, and where the result goes.

Run instruction

every month on the 1st at 09:00, read last month's query history in the warehouse with read-only access and find the ten queries and dbt models that cost the most. Post each here with its cost, how often it ran, what runs it and one concrete way to make it cheaper. Don't change any warehouse setting or model: suggest only.

RuntimeThe computer and coding agent that run it.Mac mini · Claude Code
DestinationWhere Merlin posts the result. Choose None when the instruction already acts in your tools.#data

Before and after

Warehouse costs get a monthly look with fixes attached.

Without Merlin

Someone exports a month of query history, matches the costly queries to models and works out a fix for each.

  1. 01Open the cost dashboard
  2. 02Query last month's history
  3. 03Sort by credits used
  4. 04Match queries to models
  5. 05Ask who owns each service account
  6. 06Read each costly model
  7. 07Write a fix for each
  8. 08Post the list in #data

With Merlin

The list arrives on the first of the month, each line with a way to cut its cost.

  1. Day 1 of every month at 09:00Monthly schedule posting to #data
  2. Reads the month's query historyClaude Code with Snowflake and dbt
  3. The ten costliest in #dataSuggestions only, nothing changed

Setup

Give your agent the warehouse and dbt, then schedule the review from #data.

Set these up once and the list arrives in #data on the 1st of every month. Merlin only suggests, so nothing in the warehouse changes.

  1. 01Connect a machineRuntimeInstall the Merlin desktop app or CLI on a computer running Claude Code or Codex. You can also use a machine a teammate shares with your workspace.
  2. 02Add Merlin to SlackIntegrationsInstall the Slack app and add Merlin to the channel you work in. A private channel needs /invite @Merlin.
  3. 03Add Snowflake or Databricks to your agentYour agent's MCPConnect the Snowflake or Databricks MCP server to Claude Code or Codex on the machine that runs this. Its credentials stay on that machine.
  4. 04Add dbt to your agentYour agent's MCPConnect the dbt MCP server to Claude Code or Codex on the machine that runs this. Its credentials stay on that machine.
  5. 05Grant access to query historyYour agent's MCP

    In Snowflake, query history and credits live in the ACCOUNT_USAGE views of the SNOWFLAKE database, so the role the agent signs in with needs access to them. In Databricks, they come from the system.query and system.billing tables. Read-only is enough.

  6. 06Paste the setup promptAutomationsSend the prompt below to @Merlin in Slack, in the channel it should post to. Merlin creates the automation and tells you what it set up.

Prompt

Create the monthly cost review with one message in #data.

@Merlin every month on the 1st at 09:00, read last month's query history in the warehouse with read-only access and find the ten queries and dbt models that cost the most. Post each here with its cost, how often it ran, what runs it and one concrete way to make it cheaper. Don't change any warehouse setting or model: suggest only.

#data

Once, when you send it

  1. PromptYou send the prompt to @Merlin
  2. AutomationMerlin creates the automation

Every scheduled run

  1. ScheduleThe schedule starts a run
  2. RuntimeMerlin picks the creator's machine first
  3. ContextThe run gathers context
  4. WorkClaude Code or Codex reads the query history
  5. ResultMerlin posts the costliest queries in #data
  6. SteeringReplies in its thread follow up

Bring your coding agents into the tools your team already uses.

Let your whole team hand work to Claude Code and Codex today. Connect one machine and add Merlin to Slack, Linear or GitHub. 14-day free trial, no API keys, no card.