Spanner Basics

作者 google55b4e13eba6d無授權條款21K 個星標收錄於 2026年10月8日更新於 2026年10月8日儲存庫今天更新

Assists in provisioning instances and databases, designing performant schemas, and querying data in Spanner. Use when designing primary keys, writing SQL queries or client library code, or diagnosing performance issues.

AI 產生的概覽

指導 Google Cloud Spanner 的執行個體與資料庫管理、結構定義設計、查詢與效能診斷。

功能
此技能提供使用 Google Cloud Spanner(一種全受管、具備全域交易一致性的資料庫服務)的工作流程與參考指引。內容涵蓋佈建執行個體與資料庫、設計高效能結構定義(例如主鍵選擇與交錯資料表)、撰寫 SQL 與用戶端程式庫程式碼,以及透過 SPANNER_SYS 資料表診斷慢速查詢。它也附帶 CLI 用法、IAM 安全性、Terraform、PostgreSQL 方言、佇列與 Spanner MCP 伺服器等參考文件。此技能不含指令碼,僅有指示與參考資料。
適用情境
適用於設計 Spanner 主鍵或結構定義、撰寫 Spanner SQL 或用戶端程式庫程式碼、套用 DDL 變更,或排查效能問題時。在佈建 Spanner 執行個體與資料庫,或使用 PostgreSQL 方言、Terraform、MCP 伺服器時同樣適用。
執行需求
需要存取 Google Cloud Spanner,並使用 gcloud CLI 執行執行個體、資料庫與 DDL 操作;相關流程還需要用戶端程式庫或 Terraform。對非模擬器變更需要 Google Cloud 驗證,技能要求在 DML、DDL 或破壞性操作前取得使用者明確確認。此技能不附指令碼,只有參考文件;對於參考文件未涵蓋的產品資訊,提到了 Developer Knowledge MCP 搜尋工具。

Spanner Basics

This skill provides core workflows and guidance for administering and developing with Google Cloud Spanner, a fully managed, mission-critical database service offering global transactional consistency and automatic, synchronous replication for high availability.

Core Principles

  • Performance First: Spanner scales horizontally. Efficiency is tied to Primary Key design. Always warn against using monotonically increasing/decreasing values (like sequential timestamps) as the first part of a primary key to avoid hotspots.
  • Schema Design: Prefer interleaved tables for strongly related parent-child data that is frequently accessed together.

Safety

[!CAUTION] CRITICAL INSTRUCTION: You MUST obtain explicit user confirmation before making any non-emulator database changes (DML or DDL) or destructive operations (such as dropping tables, indexes, or any other Spanner resources). Do not execute them automatically; instead, output the command (e.g., gcloud spanner databases ddl update) and ask for explicit user approval. When database access is unavailable or authentication fails, do not block on trying to verify the existence of the instance, database, or table. Assume the provided resources exist and directly generate the DDL commands.

Common Workflows

Schema Evolution & DDL

  1. Use gcloud spanner databases ddl update to apply schema updates (such as CREATE, ALTER, or DROP tables and indexes).
  2. Reference schema-design.md [blocked] for guidelines on primary key selection and interleaved tables.

Diagnosing Performance Issues

  1. Use SPANNER_SYS tables to identify slow or resource-intensive queries.
  2. For example, query SPANNER_SYS.QUERY_STATS_TOP_HOUR to find queries with the highest CPU usage.

Reference Directory

  • Core Concepts [blocked]: Explanation of Spanner internals, architecture, and design.
  • CLI Usage [blocked]: Essential gcloud spanner command-line operations for managing instances and databases.
  • IAM Security [blocked]: Roles, permissions, and data governance best practices for Spanner.
  • Client Library Usage [blocked]: Using Google Cloud client libraries for Spanner (Java, Go, Python, Node.js).
  • Terraform Usage [blocked]: Infrastructure as Code examples for provisioning Spanner instances and databases.
  • MCP Usage [blocked]: Using the Spanner remote MCP server.
  • PostgreSQL Dialect [blocked]: Best practices and examples for using the PostgreSQL interface in Spanner.
  • Queues Usage [blocked]: Cloud Spanner Queues: mental model, design constraints, and links related to transactional message queues.
  • Schema Design [blocked]: Guidelines on primary key selection and interleaved tables for performance.

If you need product information that's not found in these references, use the search_documents tool of the Developer Knowledge MCP server.

來源與署名

來源:google/skills位於skills/cloud/spanner-basics提交55b4e13

授權條款: 無授權條款

內容歸原作者所有。SourceWeft 從公開儲存庫中收錄這些內容。

檢舉或申請下架

更多來自 google/skills 的技能