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.
- Starts whenA monthly schedule runs on the
1stat09:00and posts to#data Merlin worksClaude Code or Codex reads last month's query history in Snowflake or Databricks and matches the costly queries to dbt models
- 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.Claude Code or Codex reads last month's query history in Snowflake or Databricks with read-only access and matches the costly queries to dbt models.
The post lists the ten costliest queries and models with their cost, how often they ran, what runs them and one way to make each cheaper. Nothing is changed.
A monthly schedule starts a run on the 1st at 09:00 and posts to #data.
Claude Code or Codex reads last month's query history in Snowflake or Databricks with read-only access and matches the costly queries to dbt models.
The post lists the ten costliest queries and models with their cost, how often they ran, what runs them and one way to make each cheaper. Nothing is changed.
Overview
Agents
Skills
Memory
Automations
Integrations
Settings
Most expensive queries
PauseDetailsRun history
Trigger
When Merlin runs it.
Run
What Merlin does each time, where it runs, and where the result goes.
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.
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.
- 01Open the cost dashboard
- 02Query last month's history
- 03Sort by credits used
- 04Match queries to models
- 05Ask who owns each service account
- 06Read each costly model
- 07Write a fix for each
- 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.
- Day 1 of every month at
09:00Monthly schedule posting to #data Reads the month's query historyClaude Code with Snowflake and dbt
- 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.
- 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.
- 02Add Merlin to SlackIntegrationsInstall the Slack app and add Merlin to the channel you work in. A private channel needs
/invite @Merlin. - 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.
- 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.
- 05Grant access to query historyYour agent's MCP
In Snowflake, query history and credits live in the
ACCOUNT_USAGEviews of theSNOWFLAKEdatabase, so the role the agent signs in with needs access to them. In Databricks, they come from thesystem.queryandsystem.billingtables. Read-only is enough. - 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.
Once, when you send it
- PromptYou send the prompt to @Merlin
- AutomationMerlin creates the automation
Every scheduled run
- ScheduleThe schedule starts a run
- RuntimeMerlin picks the creator's machine first
- ContextThe run gathers context
- WorkClaude Code or Codex reads the query history
- ResultMerlin posts the costliest queries in #data
- SteeringReplies in its thread follow up
Related use cases
More data tasks you can hand to Merlin.
- IntegrationsYour agent's MCP
Data
Fix a failed overnight dbt run
Mention Merlin under a failed dbt or Databricks job. It reproduces the failure against a dev schema and opens a fix pull request with the root cause.
@Merlinunder a failed job post in#dataA fix pull request with the root cause - IntegrationsYour agent's MCP
Data
Check what a dbt change does to the data
Mention Merlin on a dbt pull request to see its effect before it merges. It builds the changed models in dev and comments the row counts and changed values against production.
@usemerlin-aiin a pull request commentA data diff comment on the pull request - IntegrationsYour agent's MCP
Data
Add a new metric as a dbt model
Delegate a metric request in Linear to Merlin. It writes the dbt model with tests and docs, runs it in dev and links the pull request on the issue.
Metric request delegated to MerlinPull request linked on the issue
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.