Notícias
SQLite basta pro agente IA (não precisa Postgres caro)
Notícias
5 min de leitura
30 de maio de 2026

SQLite basta pro agente IA (não precisa Postgres caro)

SQLite é suficiente (agente IA pode rodar). Não precisa Postgres. Cost cai (sem managed DB). ROI explode.

Equipe OpenClaw

Equipe OpenClaw · Time de Engenharia & Produto

A Equipe OpenClaw é formada por engenheiros, designers e especialistas em IA dedicados a construir a melhor plataforma de agentes conversacionais para negócios brasileiros. Combinamos expertise…


SQLite basta pro agente IA (não precisa Postgres caro)

Você tem startup.

Seu startup: agente IA no WhatsApp (atendimento ao cliente).

Você pensa:

"Agente IA precisa de database (pra armazenar conversations).

Database precisa ser robusto (Postgres, MySQL, DynamoDB).

Database robusto é caro (R$ 500-2.000/mês).

Agora startup precisa pagar database (além de infrastructure).

ROI é frágil (custo é alto, revenue é baixo).

Maybe agente IA não é viável (pra startup)."

But wait.

Recent news (May 2026):

"SQLite is all you need (for durable workflows).

"Finding: SQLite é sufficient (for many use cases).

"Benefit: SQLite é simple, free, reliable.

"Implication: Você não precisa Postgres (pra agente IA)."

You realize:

"Wait.

SQLite é database.

SQLite é free (open-source).

SQLite é simple (single file).

SQLite pode store conversations (conversations são SQL data).

SQLite pode ser sufficient (pra agente IA, especialmente startup).

Maybe agente IA é viable (usando SQLite).

Let me think about this."


O problema (agente IA infrastructure é caro, startup não consegue pagar)

Why database costs are killing agente IA startups

THE DATABASE COST PROBLEM:

Scenario: Startup building agente IA

Infrastructure costs (typical):

  1. Compute (agente runs on server)

    • Option 1: AWS EC2 (t3.small): R$ 100/month
    • Option 2: Heroku: R$ 500+/month
    • Option 3: Vercel: R$ 200-500/month
    • Cost: R$ 100-500/month
  2. Database (store conversations)

    • Option 1: AWS RDS (Postgres): R$ 500+/month
    • Option 2: Heroku Postgres: R$ 500-1.000/month
    • Option 3: PlanetScale (MySQL): R$ 300-500/month
    • Option 4: MongoDB Atlas: R$ 500+/month
    • Cost: R$ 300-1.000/month
  3. Storage (backup, files)

    • AWS S3: R$ 50-100/month
    • Cost: R$ 50-100/month
  4. Monitoring, logging, etc

    • Sentry, DataDog: R$ 100-200/month
    • Cost: R$ 100-200/month
  5. LLM API (agente uses OpenAI, Claude, etc)

    • OpenAI: R$ 500-1.000/month (early stage)
    • Claude: R$ 300-500/month
    • Cost: R$ 300-1.000/month

Total monthly cost:

  • Compute: R$ 100-500
  • Database: R$ 300-1.000 ← BIGGEST COST
  • Storage: R$ 50-100
  • Monitoring: R$ 100-200
  • LLM API: R$ 300-1.000

Total: R$ 850-2.800/month (minimum)

Average: R$ 1.500-2.000/month

Yearly: R$ 18.000-24.000/year

For startup:

  • Revenue (first 6 months): Maybe R$ 0 (still building)
  • Cost: R$ 9.000-12.000 (6 months)
  • Profit: -R$ 9.000 (loss)

Problems:

  1. Database is expensive (R$ 300-1.000/month alone)
  2. Database doesn't generate revenue (it's cost)
  3. Startup can't afford (before making money)
  4. Therefore: Agente IA startup is not viable (cost is too high)

WHAT IF we remove database cost?

Using SQLite instead of Postgres:

  1. Compute: R$ 100-500 (same)
  2. Database: R$ 0 (SQLite is free!) ← HUGE SAVINGS
  3. Storage: R$ 50-100 (same)
  4. Monitoring: R$ 100-200 (same)
  5. LLM API: R$ 300-1.000 (same)

Total: R$ 550-1.800/month (instead of 850-2.800)

Savings: R$ 300-1.000/month (entire database cost)

Yearly savings: R$ 3.600-12.000

For startup:

  • Revenue (first 6 months): Maybe R$ 0-5.000
  • Cost: R$ 3.300-10.800 (6 months, with SQLite)
  • Cost (without SQLite): R$ 5.100-16.800 (6 months, with Postgres)
  • Difference: R$ 1.800-6.000 saved (using SQLite)

Implication:

  • Startup can afford agente IA (with SQLite)
  • Startup can survive longer (with SQLite, lower burn rate)
  • Startup can reach revenue faster (with lower cost)
  • Therefore: Agente IA startup is viable (with SQLite)

Why startups choose expensive databases (and shouldn't)

WHY STARTUPS OVER-ENGINEER DATABASE:

  1. Cargo-cult engineering ("everyone uses Postgres")

    • Belief: "Postgres is standard" (for startups)
    • Belief: "Postgres is what you need" (for SaaS)
    • Reality: Postgres is overkill (for agente IA, early stage)
    • Problem: Startup pays R$ 500+/month (unnecessarily)
  2. Scalability anxiety ("what if we grow?")

    • Fear: "What if we get 1M users?" (unlikely, early stage)
    • Belief: "We need to build for scale" (premature optimization)
    • Reality: SQLite scales to 10k+ concurrent users (for most cases)
    • Problem: Startup pays R$ 500+/month (for hypothetical scale)
  3. Feature envy ("we need transactions, ACID, replication")

    • Belief: "SQLite can't do X" (often false)
    • Reality: SQLite has transactions, ACID, good locking
    • Reality: SQLite doesn't have built-in replication (but not needed early)
    • Problem: Startup chooses Postgres (for features they don't need)
  4. Resume-driven development ("Postgres looks better")

    • Belief: "I'll look better" (using "enterprise" database)
    • Reality: Building working product > fancy tech stack
    • Problem: Startup pays R$ 500+/month (for ego)
  5. False sense of safety ("managed database is safer")

    • Belief: "Managed database is safer" (Postgres on RDS)
    • Reality: SQLite with backups is reliable (and cheaper)
    • Problem: Startup pays R$ 500+/month (for false safety)

THE TRUTH ABOUT SQLite:

  1. SQLite is reliable

    • Used by: Firefox, Chrome, Skype, Dropbox, Slack (internally)
    • Uptime: 99.9999%+ (no downtime)
    • Durability: ACID compliance (all or nothing transactions)
    • Problem: None (SQLite is rock-solid)
  2. SQLite is fast

    • Throughput: Millions of operations/second (on disk)
    • Latency: <1ms for simple queries
    • Problem: None (SQLite is fast for most use cases)
  3. SQLite is simple

    • Setup: Copy a file (that's it)
    • Backup: Copy a file (that's it)
    • Deploy: Include the file (that's it)
    • Problem: None (SQLite is simple)
  4. SQLite is free

    • Cost: $0 (open-source)
    • No licensing: Free for commercial use
    • No vendor lock-in: Can migrate anytime
    • Problem: None (SQLite is free)
  5. SQLite is sufficient

    • For agente IA: Store conversations, logs, embeddings
    • For startup: Scale to thousands of concurrent users
    • For production: Used by companies like Slack, Dropbox
    • Problem: None (SQLite is sufficient for most cases)

WHEN TO USE SQLITE:

  • Early stage (< 10k conversations/day): USE SQLite
  • Single region (don't need multi-region replication): USE SQLite
  • Simple data (conversations, logs): USE SQLite
  • Budget-conscious (startup): USE SQLite

WHEN NOT TO USE SQLite:

  • Distributed system (need multi-region): Maybe Postgres
  • Extreme scale (1M conversations/day): Maybe Postgres
  • Complex transactions (rare for agente IA): Maybe Postgres
  • But: Even then, SQLite can work (with caching layer)

A solução (use SQLite pro agente IA, save R$ 300-1.000/month)

Strategy 1: SQLite for agente IA workflows

HOW TO USE SQLITE FOR AGENTE IA:

  1. Store conversations (in SQLite)

    • Table: conversations
    • Columns: id, customer_id, message, response, timestamp, embedding
    • Size: 1M conversations = ~1GB (compressible)
    • Query: SELECT * FROM conversations WHERE customer_id = ?
    • Performance: <1ms (indexed)
    • Benefit: All conversations in one file
  2. Store customer profiles (in SQLite)

    • Table: customers
    • Columns: id, name, email, phone, preferences, created_at
    • Size: 10k customers = ~10MB
    • Query: SELECT * FROM customers WHERE id = ?
    • Performance: <1ms (indexed)
    • Benefit: Customer context for agente
  3. Store agente logs (in SQLite)

    • Table: logs
    • Columns: id, agente_id, level, message, timestamp
    • Size: 1M logs = ~500MB (per month)
    • Query: SELECT * FROM logs WHERE timestamp > ?
    • Performance: <1ms (indexed, with retention policy)
    • Benefit: Debug agente issues
  4. Store embeddings (in SQLite)

    • Table: embeddings
    • Columns: id, conversation_id, embedding (vector)
    • Size: 1M embeddings = ~5GB (1536-dim vectors)
    • Query: Similarity search (using vector extension)
    • Performance: <1ms (with vector index)
    • Benefit: Semantic search (similar conversations)
  5. Backup strategy (SQLite file)

    • Local: Copy SQLite file daily (to S3 or similar)
    • Remote: Store backup on S3 (R$ 50-100/month)
    • Recovery: Restore from backup (if needed)
    • Benefit: Cheap backup (just copy a file)

Example setup: python import sqlite3 from datetime import datetime

Open database

db = sqlite3.connect('agente.db')

Create tables

db.execute(''' CREATE TABLE IF NOT EXISTS conversations ( id INTEGER PRIMARY KEY, customer_id TEXT NOT NULL, message TEXT NOT NULL, response TEXT NOT NULL, timestamp DATETIME DEFAULT CURRENT_TIMESTAMP, embedding BLOB -- vector data ) ''')

db.execute('CREATE INDEX IF NOT EXISTS idx_customer ON conversations(customer_id)')

Store conversation

def store_conversation(customer_id, message, response, embedding): db.execute( 'INSERT INTO conversations (customer_id, message, response, embedding) VALUES (?, ?, ?, ?)', (customer_id, message, response, embedding) ) db.commit()

Query conversations

def get_conversations(customer_id): cursor = db.execute( 'SELECT * FROM conversations WHERE customer_id = ? ORDER BY timestamp DESC', (customer_id,) ) return cursor.fetchall()

Backup

import shutil shutil.copy('agente.db', '/backup/agente_backup.db')

Cost breakdown:

  • Compute: R$ 100-500/month (same)
  • Database: R$ 0 (SQLite is free) ← SAVINGS
  • Storage (backup): R$ 50-100/month (S3)
  • LLM API: R$ 300-1.000/month (same)

Total: R$ 450-1.600/month (instead of 850-2.800)

Savings: R$ 300-1.000/month (entire database cost)

Strategy 2: SQLite + caching layer (for scale)

IF YOU NEED MORE SCALE (but still want to save):

Setup: SQLite + Redis (caching)

  1. SQLite: Persistent storage (conversations, logs)
  2. Redis: Cache layer (fast reads, R$ 50-100/month)
  3. Benefit: Scales to 10x more concurrent users
  4. Cost: R$ 50-100/month (instead of R$ 500-1.000 for Postgres)
  5. Savings: R$ 400-900/month

Architecture:

Customer request ↓ Check Redis cache ↓ If hit: Return cached response (fast) If miss: Query SQLite ↓ Store in Redis (expire in 1 hour) ↓ Return response

Benefit:

  • Conversations served from cache (R$ 50-100/month)
  • Persistent data in SQLite (R$ 0)
  • Scales to millions of requests/day (with caching)
  • Cost: R$ 50-100/month (instead of R$ 500-1.000)

Example code: python import redis import sqlite3 import json

redis_client = redis.Redis(host='localhost', port=6379) db = sqlite3.connect('agente.db')

def get_customer_context(customer_id): # Check cache first cached = redis_client.get(f"customer:{customer_id}") if cached: return json.loads(cached) # Fast, from cache

# Query database
cursor = db.execute(
    'SELECT * FROM conversations WHERE customer_id = ? ORDER BY timestamp DESC LIMIT 10',
    (customer_id,)
)
conversations = cursor.fetchall()

# Store in cache (expire in 1 hour)
redis_client.setex(
    f"customer:{customer_id}",
    3600,  # 1 hour
    json.dumps(conversations)
)

return conversations

Cost: R$ 50-150/month (SQLite + Redis) Savings: R$ 300-950/month (vs Postgres)

Strategy 3: SQLite replication (for reliability)

IF YOU NEED HIGH AVAILABILITY (but still want to save):

Setup: SQLite + Litestream (replication)

  1. SQLite: Primary database (on your server)
  2. Litestream: Replicates to S3 (continuous backups)
  3. Benefit: Data is safely replicated (resilient)
  4. Cost: R$ 50-100/month (S3 storage)
  5. Savings: R$ 300-900/month (vs Postgres RDS)

How Litestream works:

Your server (SQLite file) ↓ (continuous replication) Litestream daemon ↓ (uploads changes) AWS S3 ↓ (on server failure) Restore from S3 ↓ New server starts ↓ (with restored database) No data loss

Setup:

  1. Install Litestream (open-source tool)
  2. Configure S3 bucket (for replication)
  3. Run Litestream daemon (monitors SQLite file)
  4. On server failure: Restore from S3 backup

Benefit:

  • High availability (replicated to S3)
  • Cost: R$ 50-100/month (S3)
  • Savings: R$ 300-900/month (vs Postgres RDS)
  • No vendor lock-in (SQLite is portable)

Cost: R$ 50-150/month (SQLite + Litestream + S3) Savings: R$ 300-950/month (vs Postgres)

Conclusão: SQLite basta pro agente IA (save R$ 300-1.000/month)

**O que você precisa saber:

  1. Agente IA precisa de database (pra store conversations)

    • Conversations: Customer messages, agente responses
    • Logs: Agente behavior, errors
    • Context: Customer profiles, preferences
    • All can be stored in SQLite
  2. Database é custo big (R$ 300-1.000/month com Postgres)

    • Postgres RDS: R$ 500-1.000/month
    • Cost kills startup economics (especially early stage)
    • Problem: Startup can't afford (before making revenue)
  3. SQLite é sufficient (e free)

    • Scales to thousands of concurrent users (sufficient pra startup)
    • Used by Slack, Dropbox, Chrome (production-grade reliability)
    • Cost: R$ 0 (open-source, free license)
    • Benefit: Saves R$ 300-1.000/month
  4. SQLite saves R$ 300-1.000/month (big for startup)

    • Infrastructure cost drops from R$ 850-2.800 to R$ 550-1.800/month
    • Yearly savings: R$ 3.600-12.000
    • Implication: Startup can afford agente IA (with SQLite)
    • Result: Lower burn rate, longer runway, viability
  5. Strategies to use SQLite (at different scales)

    • Strategy 1: SQLite alone (early stage, < 10k conversations/day)
    • Strategy 2: SQLite + Redis (scale, maintain cost-efficiency)
    • Strategy 3: SQLite + Litestream (reliable, resilient, still cheap)
    • All cost R$ 0-150/month (vs R$ 500-1.000 for Postgres)

Na OpenClaw, ajudamos agentes IA a:

  • AUDIT database choice (você realmente precisa Postgres?)
  • IMPLEMENT SQLite setup (conversations, logs, embeddings)
  • SCALE with caching (SQLite + Redis, if needed)
  • REPLICATE safely (SQLite + Litestream, for backup)
  • OPTIMIZE cost (drop R$ 300-1.000/month)
  • EXTEND runway (startup survives longer, reaches revenue)

Resultado: Seu agente IA é COST-EFFICIENT (SQLite, R$ 0 database) + VIABLE (startup can afford) + SCALABLE (handles growth) + RELIABLE (with backups) + PROFITABLE (lower burn rate = longer runway).

Seu agente IA roda em Postgres caro (R$ 500-1.000/month)?

Ou SQLite simples (R$ 0, saves R$ 300-1.000/month)?

Migrar pra SQLite agora →


Publicado em 30 de maio de 2026

Leia também