# Raw Data Size
Run the following command via the CLI.
```
mysql -h <<DATABASE_ENDPOINT>> -u admin -p -e "
SELECT ROUND(SUM(data_length + index_length) / (1024 * 1024 * 1024), 2) AS total_raw_data_size_gb
FROM information_schema.tables
WHERE table_schema NOT IN ('information_schema', 'mysql', 'performance_schema', 'sys');
"
```

# QPS

**Activity Types**

* Sustained - If load on DB is relatively stable and resemsbles a flat or semi-flat line, then use the upper most portion of the flat line for QPS.
* Sporadic - If load on DB is constanlty changing, determine if TiDB should be sized for peak QPS or a lower thereshold. 

## AWS

RDS > Performance Insights > (Select Time Period Reflective of Peak Loads) > DATABASE_NAME > Metrics (Dashboards) > Queries (Per second)

## GCP

CloudSQL > System Insights > MySQL Queries

## Azure

AzureDB for MySQL > Overview > Monitoring > (Select Time Period Reflective of Peak Loads) > Queries (Per second)

# I/O Mix

**Calculate Results**

* Read Percentage = (Read IOPS / (Read IOPS + Write IOPS)) * 100
* Write Percentage = (Write IOPS / (Read IOPS + Write IOPS)) * 100

**Interpert Results**

* If Read Percentage > 70%, the workload is **read-heavy**.
* If Write Percentage > 70%, the workload is **write-heavy**.
* If both percentages are close to 50%, the workload is **mixed**.

## AWS

RDS > Databases > DATABASE_NAME > Monitoring > ReadIOPS/WriteIOPS

## GCP

CloudSQL > System Insights > Disk read/write operations

## Azure

?????

# Workload Type

Look at the top 10-20 SQL Statements. If most queries are simple SELECT statements (e.g., retrieving single rows or small datasets), it’s likely an OLTP (Point Selects) workload. If queries include aggregations, joins, or complex filters, it indicates an OLAP (Analytics) workload.

## AWS

RDS > Performance Insights > (Select Time Period Reflective of Peak Loads) > DATABASE_NAME > Dimensions > Top SQL

## GCP

CloudSQL > System Insights > Top queries and tags

## Azure

??

----


# 📊 TiDB Sizing & Workload Assessment Guide

## 🔢 Raw Data Size

Run the following command via the CLI to calculate total raw data size (data + indexes):

```bash
mysql -h <DATABASE_ENDPOINT> -u admin -p -e "
SELECT ROUND(SUM(data_length + index_length) / (1024 * 1024 * 1024), 2) AS total_raw_data_size_gb
FROM information_schema.tables
WHERE table_schema NOT IN ('information_schema', 'mysql', 'performance_schema', 'sys');
"
```

---

## ⚙️ Queries Per Second (QPS)

### 🧠 Activity Types

- **Sustained:**  
  Load appears flat or semi-flat — use the **upper portion** of the line as QPS.
- **Sporadic:**  
  Load fluctuates — determine whether to size for **peak QPS** or a lower threshold depending on business needs.

### ☁️ Cloud Provider Guidance

- **AWS:**  
  `RDS > Performance Insights > [Select Peak Timeframe] > DB_NAME > Metrics > Queries (Per second)`

- **GCP:**  
  `CloudSQL > System Insights > MySQL Queries`

- **Azure:**  
  `Azure DB for MySQL > Overview > Monitoring > [Select Peak Timeframe] > Queries (Per second)`

---

## 📈 I/O Mix

### 🧮 Calculate Read/Write Percentages

```
Read %  = (Read IOPS / (Read IOPS + Write IOPS)) * 100  
Write % = (Write IOPS / (Read IOPS + Write IOPS)) * 100
```

### 🧠 Interpret the Results

- **Read-heavy:** Read % > 70%
- **Write-heavy:** Write % > 70%
- **Mixed:** Both close to 50%

### ☁️ Cloud Provider Guidance

- **AWS:**  
  `RDS > Databases > DB_NAME > Monitoring > ReadIOPS / WriteIOPS`

- **GCP:**  
  `CloudSQL > System Insights > Disk read/write operations`

- **Azure:**  
  *TBD — Not clearly documented*

---

## 🧵 Workload Type

Analyze the **top 10–20 SQL statements**:

- **OLTP (Transactional):**  
  Mostly simple `SELECT` statements (e.g., key lookups, point selects)
- **OLAP (Analytical):**  
  Complex queries with joins, aggregations, and filters

### ☁️ Cloud Provider Guidance

- **AWS:**  
  `RDS > Performance Insights > [Select Peak Timeframe] > DB_NAME > Dimensions > Top SQL`

- **GCP:**  
  `CloudSQL > System Insights > Top queries and tags`

- **Azure:**  
  *TBD — Not clearly documented*
