> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cloudthinker.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Tony

> Database Engineer - Query optimization, performance tuning, analytics, multi-platform

Tony is CloudThinker's database expert, specializing in query optimization, performance tuning, backup strategies, and data analytics across SQL and NoSQL platforms.

***

## The Problem Tony Solves

Database performance degrades silently. A missing index on a growing table is invisible until P95 latency spikes and engineers wake up at 2 AM. Connection pool exhaustion looks like an application bug until someone checks the database. Slow queries consume 80% of database CPU while running hundreds of times per day — and nobody knows because there's no system connecting query analytics to infrastructure cost.

Diagnosing and fixing these problems normally requires:

* Querying `pg_stat_statements` or enabling MySQL slow query log
* Reading and interpreting execution plans (EXPLAIN ANALYZE output)
* Cross-referencing query patterns against current indexes
* Understanding PostgreSQL/MySQL configuration parameters and their tradeoffs

This is deep specialist work. Most teams don't have a dedicated DBA, so database performance issues either go unfixed or require expensive consultants.

***

## How Existing Tools Compare

| Tool                         | What It Does                                         | What's Missing                                                                      |
| ---------------------------- | ---------------------------------------------------- | ----------------------------------------------------------------------------------- |
| **AWS Performance Insights** | Visualizes database load and query waits             | AWS RDS only, requires SQL expertise to interpret, no recommendations               |
| **pganalyze**                | PostgreSQL query analytics and index recommendations | PostgreSQL-only, no conversational interface, still needs DBA interpretation        |
| **Percona Monitoring (PMM)** | Open-source database monitoring                      | Complex setup, technical dashboards, no AI analysis                                 |
| **Datadog APM**              | Application + database trace correlation             | Monitoring only, no fix recommendations, expensive at scale                         |
| **New Relic / AppDynamics**  | Full-stack observability including databases         | Visibility tool, not a decision-maker; findings still require expert interpretation |

Tony goes beyond monitoring: it reads execution plans, understands your schema context, and tells you exactly which index to create, which query to rewrite, and what configuration change to make — in plain language.

***

## How Tony Works

1. **Connects to your databases** via read access — `pg_stat_statements`, MySQL Performance Schema, RDS Performance Insights, Aurora, MongoDB profiler
2. **Identifies slow queries** by analyzing execution times, call frequency, and resource consumption — finding the highest-impact targets automatically
3. **Reads execution plans** — interprets EXPLAIN ANALYZE output to understand table scans, index misses, and join inefficiencies
4. **Recommends with precision** — generates specific `CREATE INDEX` statements, query rewrites, and configuration changes with before/after impact estimates
5. **Understands tradeoffs** — considers write overhead of new indexes, memory implications of configuration changes, and downtime requirements for schema changes

***

## Capabilities

| Domain                 | Capabilities                                                              |
| ---------------------- | ------------------------------------------------------------------------- |
| **Query Optimization** | SQL analysis, execution plans, index recommendations, query rewriting     |
| **Performance Tuning** | Connection pooling, configuration optimization, bottleneck identification |
| **Data Analytics**     | Usage patterns, trend analysis, capacity planning, metrics visualization  |
| **Operations**         | Backup/recovery, replication, maintenance, disaster recovery planning     |

***

## Supported Platforms

| Category          | Platforms                                      |
| ----------------- | ---------------------------------------------- |
| **Relational**    | PostgreSQL, MySQL, MariaDB, SQL Server, Oracle |
| **Cloud Managed** | AWS RDS, Aurora, Azure SQL, Cloud SQL          |
| **NoSQL**         | MongoDB, Redis, DynamoDB, DocumentDB           |
| **Analytics**     | Redshift, BigQuery, Snowflake                  |

***

## Prompt Patterns

### Query Analysis

```bash theme={null}
# Slow query investigation
@tony analyze slow queries on production PostgreSQL

# Specific performance target
@tony identify queries with execution time >2 seconds on orders database

# Execution plan analysis
@tony analyze execution plans for the 20 slowest queries

# Query patterns
@tony find queries that could benefit from caching
```

### Performance Optimization

```bash theme={null}
# Index recommendations
@tony analyze missing indexes that would improve performance by >10%

# Connection optimization
@tony review connection pooling configuration for high-load scenarios

# Configuration tuning
@tony optimize MySQL 8.0 configuration for high-throughput OLTP with 10k connections

# Resource analysis
@tony identify queries consuming >5% of total database CPU
```

### Database Health

```bash theme={null}
# Health check
@tony check database health and performance metrics

# Replication status
@tony assess replication lag and recommend optimization

# Storage analysis
@tony analyze database growth patterns and recommend archiving strategy

# Connection analysis
@tony analyze connection usage patterns and identify connection leaks
```

### Backup & Recovery

```bash theme={null}
# Backup verification
@tony verify backup status and recovery procedures for production databases

# DR planning
@tony create disaster recovery plan with RTO/RPO analysis

# Recovery testing
@tony recommend backup testing strategy for production databases
```

***

## Tool Usage

| Tool         | Tony Use Case                                                         |
| ------------ | --------------------------------------------------------------------- |
| `#dashboard` | Query latency (P50/P95/P99), connections, I/O, replication lag        |
| `#report`    | Performance analysis, optimization recommendations, capacity planning |
| `#recommend` | Index changes, configuration updates, query rewrites                  |
| `#alert`     | Slow queries, connection pool exhaustion, replication lag             |
| `#chart`     | Query trends, resource utilization, growth patterns                   |

### Examples with Tools

```bash theme={null}
@tony #dashboard database performance metrics for production cluster
@tony #report query performance analysis with optimization plan
@tony #recommend index optimizations prioritized by impact
@tony #alert when P95 query latency exceeds 500ms
```

***

## Effective Prompts

<CardGroup cols={2}>
  <Card title="Include Metrics" icon="chart-line">
    ```bash theme={null}
    # Good
    @tony analyze queries with
    execution time >2 seconds
    running >100 times daily

    # Avoid
    @tony make database faster
    ```
  </Card>

  <Card title="Specify Platform" icon="database">
    ```bash theme={null}
    # Good
    @tony optimize MySQL 8.0
    for read-heavy workloads
    with 10k concurrent connections

    # Avoid
    @tony check the database
    ```
  </Card>
</CardGroup>

***

## Connection Requirements

Tony requires database connections with performance metrics access:

| Platform       | Required Access                                      |
| -------------- | ---------------------------------------------------- |
| **PostgreSQL** | `pg_stat_statements`, query logs, performance schema |
| **MySQL**      | Performance Schema, slow query log, status variables |
| **RDS/Aurora** | Enhanced Monitoring, Performance Insights            |
| **MongoDB**    | Profiler, `serverStatus`, operation logs             |

***

## Common Workflows

### Performance Crisis Response

```bash theme={null}
# Step 1: Identify
@tony identify top 10 slowest queries in last hour

# Step 2: Analyze
@tony analyze execution plans for problematic queries

# Step 3: Optimize
@tony #recommend index changes and query rewrites

# Step 4: Monitor
@tony #dashboard real-time query performance
```

### Proactive Optimization

```bash theme={null}
# Step 1: Baseline
@tony #dashboard current performance metrics

# Step 2: Analyze
@tony identify optimization opportunities across all databases

# Step 3: Prioritize
@tony #recommend optimizations ranked by impact and effort

# Step 4: Automate
@tony #schedule weekly performance review
```

### Capacity Planning

```bash theme={null}
# Step 1: Analyze growth
@tony analyze database growth patterns over last 6 months

# Step 2: Forecast
@tony predict storage and compute needs for next year

# Step 3: Plan
@tony #recommend scaling strategy with cost analysis
```

***

## What's Next

<CardGroup cols={2}>
  <Card title="PostgreSQL Connection" icon="https://mintcdn.com/cloudthinker/aLd-ttc-SCW-aFky/images/icons/postgresql.svg?fit=max&auto=format&n=aLd-ttc-SCW-aFky&q=85&s=8bb2ac033d0a2ccbef51154a76e1e819" href="/guide/connections/postgresql" width="24" height="24" data-path="images/icons/postgresql.svg">
    Connect Tony to your PostgreSQL databases
  </Card>

  <Card title="MySQL Connection" icon="https://mintcdn.com/cloudthinker/aLd-ttc-SCW-aFky/images/icons/mysql.svg?fit=max&auto=format&n=aLd-ttc-SCW-aFky&q=85&s=29b74ea2b3ffacd21682ca898f6a2e43" href="/guide/connections/mysql" width="24" height="24" data-path="images/icons/mysql.svg">
    Connect Tony to your MySQL databases
  </Card>

  <Card title="Deep Response Engine" icon="triangle-exclamation" href="/guide/incident/overview">
    How Tony investigates database-related incidents automatically
  </Card>

  <Card title="Anna" icon="users" href="/guide/agents/anna">
    Coordinate Tony with [Alex](/guide/agents/alex) for infrastructure + database cost optimization
  </Card>
</CardGroup>
