AI Codex
Building Your Internal AI StackStep 5 of 8
← Prev·Next →
Infrastructure & DeploymentCross-Concept

BigQuery vs StarRocks for AI Agent Workloads

In brief

BigQuery is the default for data teams, but per-query pricing and cold start latency make it expensive when AI agents are making dozens of small queries throughout the day. StarRocks — flat monthly pricing, sub-second latency, MySQL-compatible SQL — is often a better fit.

9 min read·

Contents

Sign in to save

Most data teams already have BigQuery. It's the default for Google Cloud shops, it handles scale well, and the serverless model means you don't manage infrastructure. For traditional analytics workloads — a few large queries per day, run by analysts who are used to waiting 5-10 seconds — it works well.

AI agents are not traditional analytics workloads. They make many small queries, throughout the day, from user sessions that have latency expectations. The economics that work for BI break for agent workloads.

This isn't a verdict on BigQuery — it's genuinely excellent software. It's an honest look at where the mismatch is, and when a different database fits better.


The AI agent query pattern

Traditional BI queries: 3-5 per day, large scans, analysts tolerate 5-30 seconds of latency.

AI agent queries: 20-100+ per day per agent, small lookups, users expect 1-2 second responses.

That pattern difference matters for two things: pricing and latency.

Pricing. BigQuery charges by data scanned. A query that scans 1 TB costs about $5. That's fine when you're running it twice a day. It gets expensive when 50 agents are each running 20 queries daily.

The math: 50 agents × 20 queries/day × $0.25/query (rough estimate for typical AI-scale queries) = $250/day = $7,500/month. That's before you've done any of your other BigQuery analysis.

Latency. BigQuery has cold start time. A query that hasn't been run recently takes 2-5 seconds before it even starts processing. For a BI analyst waiting on a dashboard, that's acceptable. For an AI agent session where the user is waiting for a response, it adds up.


BigQuery: what it does well

To be fair about where BigQuery genuinely excels:

Massive scale. If you're scanning petabytes of data, BigQuery is the right tool. The serverless architecture handles data volumes that would require significant infrastructure management elsewhere.

Complex analytics. Sophisticated window functions, nested/repeated fields, BigQuery ML — for analysts doing complex analysis, these features matter.

Google Cloud integration. If you're already in GCP, BigQuery integrates cleanly with everything else: Data Studio, Looker, Pub/Sub, Cloud Functions.

No infrastructure management. You don't manage nodes, you don't worry about capacity planning, you don't deal with cluster rebalancing. It just works at any scale.

For traditional BI workloads in a GCP environment, BigQuery is hard to beat.


Where BigQuery struggles for AI agents

Per-query cost model. Every time an AI agent queries BigQuery, you pay for the data scanned. Agents don't batch queries — they respond to user questions as they come in. The cost structure that works for "run 5 reports a day" doesn't work for "answer 100 questions a day across 50 users."

You can mitigate this with:

  • Materialized views (but they add complexity)
  • Partition pruning and clustering (requires schema discipline)
  • BI Engine (reservation pricing, but adds another cost layer)
  • Caching (Anthropic prompt caching or your own — helps but doesn't solve it)

These are real solutions, but they add engineering overhead to a system that should be straightforward.

Cold start latency. BigQuery's 2-5 second cold start is invisible to a dashboard user who expects to wait. It's visible to an agent user who's watching a spinner.

Query costs for small lookups. BigQuery charges on data scanned, not rows returned. If you run SELECT * FROM customer_summary WHERE customer_id = '123' on a table with 100,000 customers, you're scanning a lot to return one row. Partitioning helps, but it requires intentional schema design.


StarRocks: what it is and why it fits differently

StarRocks is an open-source OLAP database optimized for real-time analytics. It's MySQL-compatible (your SQL just works), runs as a cluster you manage (or use a managed version), and is designed for sub-second query latency on large datasets.

The key differences for AI agent workloads:

Flat pricing. Whether you're running 5 queries or 500, your monthly cost is the same. For AI agents making frequent queries, this is a significant advantage. A t2 StarRocks cluster on a managed provider runs roughly $200-400/month regardless of query volume.

Sub-second latency. StarRocks is built for real-time query response. Typical analytical queries on millions of rows return in under a second. The cold start problem doesn't exist in the same way — the cluster is always warm.

MySQL compatibility. Your existing SQL works. No need to learn BigQuery-specific syntax or rewrite queries for a new dialect.

Index support. BigQuery doesn't have traditional indexes (it uses partitioning and clustering instead). StarRocks supports bitmap indexes, sorted keys, and materialized views — useful for the specific query patterns AI agents run (frequent lookups by customer ID, user ID, date ranges).


Direct comparison for AI workloads

Dimension BigQuery StarRocks
Pricing model Per TB scanned Flat monthly
Cold query latency 2-5 seconds < 1 second
Management overhead None (serverless) Cluster management
MySQL compatibility No (BigQuery SQL) Yes
Scale ceiling Effectively unlimited Cluster-bound (but large)
AI agent economics Expensive at volume Predictable
Setup complexity Low Medium
Ecosystem integration Deep (GCP) Vendor-neutral
Index support Partitioning/clustering Full index support

When to use each

Use BigQuery when:

  • You're already heavily invested in GCP and the integration value is real
  • Your query volume is low (< 50 queries/day across all agents)
  • You're doing complex analytics alongside AI queries — the analyst use case is primary
  • You need petabyte scale
  • You don't want to manage infrastructure

Use StarRocks when:

  • AI agents are the primary consumer of the database
  • Query frequency is high (100+ queries/day)
  • Latency matters — users expect fast responses
  • You want predictable infrastructure costs
  • Your team is comfortable managing a cluster (or using a managed StarRocks provider)

Use both when:

  • You have existing BigQuery investment and active BI usage
  • AI agents need fast, frequent queries
  • Pattern: BigQuery for batch analytics and large-scale processing, StarRocks for the agent-facing query layer

The hybrid approach lets you keep BigQuery for what it does well (large-scale analytics, GCP integration) while adding StarRocks as a purpose-built layer for AI workloads.


The migration path

If you're on BigQuery and want to add a faster, cheaper query layer for agents:

Step 1: Identify which queries your agents run most frequently. Log all MCP tool calls for a week. Find the top 10 query patterns.

Step 2: Spin up a StarRocks cluster. Managed options (CelerData, StarRocks Cloud) have reasonable free tiers for evaluation.

Step 3: Replicate the relevant tables. You don't need to move everything — just the tables your agents actually query.

Step 4: Update your MCP tools to point to StarRocks for agent queries. Keep BigQuery for batch analytics.

Step 5: Measure. Compare latency and monthly cost before and after.

The migration is mostly a data pipeline addition, not a replacement. Both databases coexist — they just handle different workloads.


The query that illustrates the difference

To make this concrete: a customer success agent running a daily brief needs to query:

  • Customer health scores for their portfolio (50 customers)
  • Open support tickets per customer
  • Renewal dates coming up in 90 days
  • Recent call activity

On BigQuery (no optimization): 4 separate queries, 2-5 second cold start on the first, ~10 seconds total, billing for all data scanned.

On StarRocks: 1-2 queries with pre-joined views, sub-second response on each, flat monthly cost regardless of frequency.

At one agent with one daily brief, the difference doesn't matter much. At 50 agents running multiple queries throughout the day, the difference is $4,000-6,000 per month and noticeably faster response times.

That's the AI agent economics argument in one example.

Related tools

Next in Building Your Internal AI Stack · Step 6 of 8

Continue to the next article in the learning path

Next article →

Weekly brief

For people actually using Claude at work.

Each week: one thing Claude can do in your work that most people haven't figured out yet — plus the failure modes to avoid. No tutorials. No hype.

No spam. Unsubscribe anytime.

What to read next

Picked for where you are now

All articles →