---
updatedAt: 2026-08-26T11:11:10.000Z
agentTools:
  projectIndex: https://docs.cast.ai/llms.txt
---

# Get a database by ID

Get a database by ID

 Returns a single database.

# OpenAPI definition

```json
{
  "openapi": "3.0.3",
  "servers": [
    {
      "url": "https://api.cast.ai/",
      "description": "US endpoint"
    },
    {
      "url": "https://api.eu.cast.ai/",
      "description": "EU endpoint"
    }
  ],
  "info": {
    "title": "Database Optimizer",
    "version": "0.0.1"
  },
  "security": [
    {
      "BearerAuth": []
    },
    {
      "ApiKeyAuth": []
    }
  ],
  "paths": {
    "/database-optimizer/database-instances/v1alpha/organizations/{organizationId}/database-instances/{databaseInstanceId}/databases/{id}": {
      "get": {
        "tags": [
          "DatabaseInstancesAPI"
        ],
        "summary": "Get a database by ID",
        "description": "Get a database by ID\n\n Returns a single database.",
        "operationId": "DatabaseInstancesAPI_GetDatabase",
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "description": "Organization identifier",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "databaseInstanceId",
            "in": "path",
            "description": "Database instance identifier.",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "id",
            "in": "path",
            "description": "Database identifier",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Database"
                }
              }
            }
          },
          "default": {
            "description": "Default error response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Status"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      },
      "ApiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key"
      }
    },
    "schemas": {
      "AdvisorStats": {
        "required": [
          "openQueryRecommendationsCount",
          "closedQueryRecommendationsCount",
          "openIndexRecommendationsCount",
          "closedIndexRecommendationsCount",
          "affectedQueriesDbTimeMs",
          "affectedQueriesDbTimePercentage",
          "affectedQueriesCount",
          "analyzedTablesCount",
          "analyzedIndexesCount"
        ],
        "type": "object",
        "properties": {
          "openQueryRecommendationsCount": {
            "type": "integer",
            "description": "Number of open query (performance) recommendations",
            "format": "uint32"
          },
          "closedQueryRecommendationsCount": {
            "type": "integer",
            "description": "Number of closed query (performance) recommendations",
            "format": "uint32"
          },
          "openIndexRecommendationsCount": {
            "type": "integer",
            "description": "Number of open index recommendations",
            "format": "uint32"
          },
          "closedIndexRecommendationsCount": {
            "type": "integer",
            "description": "Number of closed index recommendations",
            "format": "uint32"
          },
          "affectedQueriesDbTimeMs": {
            "type": "number",
            "description": "Total database time in milliseconds for queries affected by recommendations\n (-- api-linter: core::0142::time-field-type=disabled\n     aip.dev/not-precedent: This is a duration in milliseconds, not a timestamp. --)",
            "format": "double"
          },
          "affectedQueriesDbTimePercentage": {
            "type": "number",
            "description": "Percentage of total database time attributed to queries affected by recommendations",
            "format": "double"
          },
          "affectedQueriesCount": {
            "type": "integer",
            "description": "Number of distinct query templates affected by recommendations",
            "format": "uint32"
          },
          "lastUpdateTime": {
            "type": "string",
            "description": "Timestamp of the last completed analysis cycle (query processing or validation) for this database.\n Only populated on per-database responses; unset until the first cycle completes.",
            "format": "date-time"
          },
          "analyzedTablesCount": {
            "type": "integer",
            "description": "Distinct (schema, table) pairs seen in the latest index snapshot for this database.\n Only populated on per-database responses.",
            "format": "uint32"
          },
          "analyzedIndexesCount": {
            "type": "integer",
            "description": "Count of indexes seen in the latest index snapshot for this database.\n Only populated on per-database responses.",
            "format": "uint32"
          },
          "totalDbTimeMs": {
            "type": "number",
            "description": "Total database time in milliseconds for all queries (not just affected ones).\n (-- api-linter: core::0142::time-field-type=disabled\n     aip.dev/not-precedent: This is a duration in milliseconds, not a timestamp. --)",
            "format": "double"
          }
        },
        "description": "AdvisorStats aggregates query and index recommendation statistics for a scope"
      },
      "CachingSummary": {
        "required": [
          "hitRate",
          "dbTimeSavePercentage",
          "cacheHits"
        ],
        "type": "object",
        "properties": {
          "hitRate": {
            "type": "number",
            "description": "Percentage of queries served from cache",
            "format": "float"
          },
          "dbTimeSavePercentage": {
            "type": "number",
            "description": "Percentage of database time saved by caching",
            "format": "float"
          },
          "cacheHits": {
            "type": "string",
            "description": "Number of cache hits"
          },
          "projectedHitRate": {
            "type": "number",
            "description": "Projected cache hit rate as a percentage",
            "format": "float"
          },
          "projectedCacheHits": {
            "type": "string",
            "description": "Projected number of cache hits"
          },
          "projectedDbTimeSavePercentage": {
            "type": "number",
            "description": "Projected percentage of database time saved",
            "format": "float"
          },
          "totalQueries": {
            "type": "string",
            "description": "Total number of queries observed"
          },
          "dqlQueries": {
            "type": "string",
            "description": "Total number of DQL queries observed"
          },
          "totalTimeMs": {
            "type": "string",
            "description": "Total execution time in milliseconds."
          },
          "cacheMode": {
            "enum": [
              "CACHE_MODE_UNSPECIFIED",
              "ON",
              "PASSTHROUGH",
              "OFF"
            ],
            "type": "string",
            "description": "Cache mode for this database",
            "format": "enum"
          }
        },
        "description": "Caching stats"
      },
      "ConnectionsSummary": {
        "required": [
          "incoming",
          "outgoing",
          "reduction",
          "active",
          "idle"
        ],
        "type": "object",
        "properties": {
          "incoming": {
            "type": "integer",
            "description": "Connections into DBO",
            "format": "int32"
          },
          "outgoing": {
            "type": "integer",
            "description": "Connections from DBO to DB upstream",
            "format": "int32"
          },
          "reduction": {
            "type": "number",
            "description": "Percentage of reduced connections",
            "format": "float"
          },
          "active": {
            "type": "integer",
            "description": "Number of active client connections",
            "format": "int32"
          },
          "idle": {
            "type": "integer",
            "description": "Number of idle client connections",
            "format": "int32"
          },
          "maxConnections": {
            "type": "integer",
            "description": "Maximum number of connections",
            "format": "int32"
          }
        },
        "description": "Pooling stats"
      },
      "Database": {
        "required": [
          "name"
        ],
        "type": "object",
        "properties": {
          "id": {
            "readOnly": true,
            "type": "string",
            "description": "Database identifier"
          },
          "name": {
            "type": "string",
            "description": "Name of the database"
          },
          "createTime": {
            "readOnly": true,
            "type": "string",
            "description": "When the database was created",
            "format": "date-time"
          },
          "cachingSummary": {
            "readOnly": true,
            "allOf": [
              {
                "$ref": "#/components/schemas/CachingSummary"
              }
            ],
            "description": "Per-database caching statistics"
          },
          "connectionsSummary": {
            "readOnly": true,
            "allOf": [
              {
                "$ref": "#/components/schemas/ConnectionsSummary"
              }
            ],
            "description": "Per-database connection statistics"
          },
          "advisorStats": {
            "readOnly": true,
            "allOf": [
              {
                "$ref": "#/components/schemas/AdvisorStats"
              }
            ],
            "description": "Per-database advisor statistics"
          },
          "cacheConfigId": {
            "readOnly": true,
            "type": "string",
            "description": "Cache configuration identifier linked to this database"
          },
          "databaseInstanceId": {
            "readOnly": true,
            "type": "string",
            "description": "Database instance this database belongs to"
          }
        },
        "description": "A database registered on a database instance"
      },
      "GoogleProtobufAny": {
        "type": "object",
        "properties": {
          "@type": {
            "type": "string",
            "description": "The type of the serialized message."
          }
        },
        "additionalProperties": true,
        "description": "Contains an arbitrary serialized message along with a @type that describes the type of the serialized message."
      },
      "Status": {
        "type": "object",
        "properties": {
          "code": {
            "type": "integer",
            "description": "The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code].",
            "format": "int32"
          },
          "message": {
            "type": "string",
            "description": "A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client."
          },
          "details": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/GoogleProtobufAny"
            },
            "description": "A list of messages that carry the error details.  There is a common set of message types for APIs to use."
          }
        },
        "description": "The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors)."
      }
    }
  },
  "tags": [
    {
      "name": "DatabaseInstancesAPI",
      "description": "DatabaseInstancesAPI provides APIs for managing database instances"
    }
  ]
}
```