
The Cohort Retention SQL Query I Actually Use
Retention is the metric people most want and least want to write the SQL for. The chart is simple to picture: group users by the month they signed up, then track how many came back in each later month...
How to supercharge your workflow with AI

I spent a chunk of 2023 being a text-to-SQL skeptic, and I was right to be. The demos were beautiful and the reality was a model confidently joining two tables on columns that didn't share a meaning,...

Supabase is Postgres with a nice jacket on. That's a compliment. It means everything you'd do to safely connect an AI agent to plain Postgres applies here, plus a couple of Supabase-specific things wo...

My app uses Turso for its SQLite backend. Last week I was chasing a performance complaint and wanted to know which queries were pulling back the most rows. The SQLite query stats story is thinner than...

I see the same setup over and over. Someone wants their coding agent to be able to check the database, so they drop the production connection string into the agent's environment and move on. `bash exp...

Our support manager, Dana, was trying to figure out whether the onboarding redesign was actually working. Her question was simple: "How many users have completed onboarding this month?" But getting an...

I was debugging a mobile sync issue and someone asked if any devices had gone quiet, as in, no sync in over 48 hours. We use Turso for our edge SQLite database. I had Windsurf open, the code right in...

I was debugging a flaky integration test when I noticed the errors were clustering around one endpoint. The test logs said "unexpected response," which told me nothing. What I actually needed was a co...

A customer emailed asking why their team wasn't using a particular feature anymore. I was drafting a reply and wanted to check the actual usage numbers before I said anything. Our app data lives in a...

A customer emailed asking whether their data had actually synced or whether something was silently failing on their device. I knew we had a conflict table. I knew it had timestamps. I did not know the...

It was a Tuesday and someone on the ops team needed a quick number: how many distinct products did we actually sell in March, not counting refunds or test orders? A fifteen-minute Slack thread ensued...

Friday afternoon. Payroll review was coming up and someone on the ops team pinged asking which employees had logged overtime above 10 hours that week. I wasn't going to write that query by hand and I...

Our finance lead, Marcus, had a question that had been nagging him for weeks: how long does it actually take a new user to make their first purchase? He'd been getting a different answer every time he...

The ops manager messaged me at 9 AM on a Monday: "Do we have a quick way to see which products are running low?" She didn't need a dashboard. She needed an answer, right now. I was already in Windsurf...

I was pairing with a teammate on a cart abandonment feature when she asked, "How many carts have been sitting for more than a day right now?" Neither of us knew off the top of our heads. She tabbed ou...

I was prepping a one-on-one with our head of sales last week and I wanted to walk in with the top customers by lifetime value, not a guess at it. I had maybe ten minutes before the call. Pulling it up...

It was 2am and our daily order volume chart had gone flat. Not zero, just... suspiciously flat. I needed to know whether orders had actually stopped or whether the reporting query was broken. I didn't...

I inherited a Postgres schema with 94 tables last year. No ERD, minimal comments, just 94 tables and a pile of legacy migrations. I needed to understand it fast. I tried a few AI tools, and most of th...

I was elbow-deep in a performance investigation when I wanted to know which queries were hitting the database hardest. Opening a psql session, running pg_stat_statements, copying the results, formatti...

Our head of marketing, Jenna, slacked me on a Tuesday with a single question: "How many active subscribers do we have right now? Churn feels weird this week." She wasn't asking me to write a dashboard...

I was in the middle of a refactor when a colleague pinged me asking which users had started a trial but never converted. I didn't want to tab out, spin up a DB client, and write the query from scratch...

I was three hours into a payment refactor when I realized I had no idea how many orders were actually failing. The code was in front of me. The database was... somewhere else. I had a terminal open, a...

I was halfway through writing a board update last quarter when our head of growth pinged me asking for our revenue from new customers that month. Not the total. Just new customers. I knew the data was...

I was elbow-deep in a refactor when a Slack ping landed: "hey can you pull a list of users who signed up last week but never came back?" Not a big ask. But switching contexts, opening a psql terminal,...

I spent a weekend in April reading source code for every Postgres MCP server I could find — open source, commercial, side projects, archived references. There are more than you'd think, and they're mo...

A teammate pinged me last week asking why two rows in the events table had a started_at stored as "2024-03-15" (a string) while the rest had Unix timestamps. They'd been hunting this for an hour. I ju...

You're debugging a customer complaint and someone on the team asks "how many orders did this user place in the last 90 days?" You know the answer is in MySQL. You also know you'll need to write the JO...

Someone on my team asked how many users had churned in the last 30 days. Simple question. But to answer it, I needed to open a psql session, remember the exact column names in our subscriptions table,...

There's a class of prompt injection attack that nobody's writing about, probably because it's been overshadowed by the "agent reads a file with malicious instructions" version. But it's the one I thin...

You've probably read three "What is MCP?" posts already. They all start with "MCP is a protocol for connecting AI models to external tools and data" and proceed to be the same post. I want to write th...

There's a workflow I get asked about all the time and it goes roughly: "I want Claude Code to be able to answer questions about my production database, but I don't want to give it my prod URL." This i...

If you're going to let an AI agent touch a real Postgres, the smallest thing you can build that actually keeps you safe is an allowlist. Not a database role — a parsed-SQL-against-a-list check, before...

There's a comforting belief in the AI database tooling world that goes "we set the connection to read-only, so we're safe." Half the AI database MCP servers I've read source for use this as their enti...

If you're shipping an AI feature in 2026 and you haven't figured out database access, you're behind. If you've figured it out by handing the agent a prod Postgres URL, you're behind in a different and...

In late 2025 Anthropic moved 14 of its reference MCP servers to a archived directory in modelcontextprotocol/servers. The Postgres one was the headline because it's the one teams were actually using....

Last month, @modelcontextprotocol/server-postgres was downloaded 312,391 times. The month before that, 301,440. November 2025 it was 100,059. Installs have tripled in five months and they're still cli...

Imagine the world 12 months from now. AI agents are everywhere and they are genuinely powerful. They write code, ship features, debug production issues, and quietly do half of the boring work nobody w...

I've been connecting my coding agents to everything: Datadog logs, Linear, Slack. It still feels like I hit the same wall every time I actually need to debug something serious. The model can read the...

Your AI agents are about to become your most productive employees. But right now, they're working blind. I've spent the last year building infrastructure that connects AI agents to databases. And the...

Your AI agents need data. But giving them raw database access is terrifying. Today we're launching a new direction for QueryBear: a secure gateway between your AI agents and your database. Connect you...

I've been connecting my coding agents to everything: Datadog logs, Linear, Slack. It still feels like I hit the same wall every time I actually need to debug something serious. The model can read the...

I've been thinking lately about a line people don't love to cross: giving more people access to the database. There's still a stigma, like it's a holdover from when "database access" meant shared admi...

The phrase "data-driven" gets used as if it means "we look at numbers." It almost never means that. What it means at most companies is "two engineers look at numbers and tell the other ninety-eight pe...

There is a spectrum from "AI writes everything and runs it" to "humans write everything by hand." Almost every team I see picks one of the two endpoints. Both are wrong for SQL. The right point is in...

If you have ever been on a small data team at a growing company, you know the feeling. The Slack queue is full. Every Tuesday someone asks for a quick refund report. Every other Friday it's a churn co...

I sell a tool that writes SQL for you. I'm going to argue you should still learn SQL. Both things can be true. The reason is simple: if you can't read what the AI wrote, you can't catch when it's wron...

I get the "is AI going to replace Metabase" question almost every week. The honest answer is "for a lot of teams, yes — but not in the way most people are pitching it." I want to walk through the actu...

When QueryBear's AI writes SQL against your database, it has to know your schema — every table, every column, every type, every foreign key. Without that context, it's guessing. The naive way to do th...

Every internal tool I've ever shipped has eventually broken, and I've watched the same thing happen at every company I've worked at. It's not bad engineering. It's a structural problem. I want to lay...

The headline feature when I started building QueryBear was natural-language SQL. The thing I now use ten times a day is the boring one I almost didn't ship: saved queries. They're also the feature tha...

I have sat in too many "we need to be more data-driven" all-hands. They are almost always preceded by a quarter where the team made a decision on gut and it didn't go well. They are almost never follo...

I'm an engineer by trade. And when I look a couple years ahead, the landscape looks completely different than it does today. Right now, AI is a tool that augments engineers. An idea comes from somewhe...