# Cluster Detail Queries

Use direct `SELECT *` lookups when the user asks to inspect cluster detail rows. Default to non-deleted clusters by adding `cluster_deleted_time IS NULL`, except when querying one specific cluster by `cluster_id`. See SKILL.md for shared rules.

## By cluster ID

For requests like "Show details for cluster `123456`":

```sql
SELECT *
FROM `gcp-digital-bi.model_tidbcloud.dws_cloud_all_clusters_component_detail_basic_info`
WHERE CAST(cluster_id AS STRING) = '<cluster_id_from_user>';
```

## By cluster name (fuzzy)

For requests like "Show details for clusters matching `manus`":

```sql
SELECT *
FROM `gcp-digital-bi.model_tidbcloud.dws_cloud_all_clusters_component_detail_basic_info`
WHERE LOWER(cluster_name) LIKE LOWER('%<cluster_name_from_user>%')
  AND cluster_deleted_time IS NULL;
```

## By tenant ID

For requests like "Show active clusters for tenant `123456`":

```sql
SELECT *
FROM `gcp-digital-bi.model_tidbcloud.dws_cloud_all_clusters_component_detail_basic_info`
WHERE CAST(tenant_id AS STRING) = '<tenant_id_from_user>'
  AND cluster_deleted_time IS NULL;
```

## By tenant name + service plan

For requests like "Show Starter clusters for tenant `manus`":

```sql
SELECT
  CAST(tenant_id AS STRING) AS tenant_id,
  ANY_VALUE(tenant_name) AS tenant_name,
  ANY_VALUE(tenant_alias) AS tenant_alias,
  ANY_VALUE(tenant_internal_user) AS tenant_internal_user,
  COUNT(*) AS starter_cluster_count
FROM `gcp-digital-bi.model_tidbcloud.dws_cloud_all_clusters_component_detail_basic_info`
WHERE (
    LOWER(tenant_name) LIKE LOWER('%<tenant_name_from_user>%')
    OR LOWER(tenant_alias) LIKE LOWER('%<tenant_name_from_user>%')
  )
  AND cluster_service_plan = 'Starter'
  AND cluster_deleted_time IS NULL
GROUP BY CAST(tenant_id AS STRING)
ORDER BY starter_cluster_count DESC;
```

Swap `'Starter'` for the plan the user named, or expand to `cluster_service_plan IN ('Starter', 'Essential', 'Premium')` for the full TiDB X scope.
