{"data":{"slug":"github-google-skills-skills-cloud-spanner-basics-27ea5a91e46c","title":"Spanner Schema Design & DDL Management","summary":"Design efficient schemas, apply schema updates using DDL commands, and diagnose performance issues in Cloud Spanner. This skill provides guidance on primary key selection, interleaved tables, and using SPANNER_SYS tables for query diagnostics.","url":"https:\/\/skillshunter.net\/skills\/github-google-skills-skills-cloud-spanner-basics-27ea5a91e46c","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/github-google-skills-skills-cloud-spanner-basics-27ea5a91e46c","markdown_url":"https:\/\/skillshunter.net\/skills\/github-google-skills-skills-cloud-spanner-basics-27ea5a91e46c.md","download_url":"https:\/\/skillshunter.net\/skills\/github-google-skills-skills-cloud-spanner-basics-27ea5a91e46c\/download","category":{"slug":"software-development","name":"Software & Development"},"editor_note":"Before executing any non-emulator database changes (DML or DDL) or destructive operations, obtain explicit user confirmation. Prefix `gcloud` commands with `CLOUDSDK_METRICS_REQUEST_ATTRIBUTION=\"agent-skills\/1.0 (skill:spanner-basics)\"` and append `agent-skills\/1.0 (skill:spanner-basics)` to `User-Agent` headers when running commands directly in the terminal.","instructions":"---\nname: spanner-basics\nmetadata:\n  version: \"1.1.2\"\n  category: Databases\ndescription: >-\n  Assists in provisioning instances and databases, designing performant schemas, and querying data in Cloud Spanner on Google Cloud. Use when designing primary keys, writing SQL queries or client library code, or diagnosing performance issues.\n---\n\n# Spanner Basics\n\nThis skill provides core workflows and guidance for administering and developing with Cloud Spanner on Google Cloud, a fully managed, mission-critical database service offering global transactional consistency and automatic, synchronous replication for high availability.\n\n## Attribution\n\n**MUST READ**: Before executing any `gcloud`, REST API, or MCP command, you\nMUST read [Usage Attribution](references\/attribution.md). For commands executed\ndirectly in the terminal (never in generated scripts, Terraform, or user code),\nprefix `gcloud` with\n`CLOUDSDK_METRICS_REQUEST_ATTRIBUTION=\"agent-skills\/1.0 (skill:spanner-basics)\"`\nand append `agent-skills\/1.0 (skill:spanner-basics)` to `User-Agent` headers.\n\n## Core Principles\n\n-   **Performance First:** Spanner scales horizontally. Efficiency is tied to\n    Primary Key design. Always warn against using monotonically increasing\/decreasing\n    values (like sequential timestamps) as the first part of a primary key to avoid hotspots.\n-   **Schema Design:** Prefer interleaved tables for strongly related parent-child data\n    that is frequently accessed together.\n\n## Safety\n\n> [!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.\n> 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.\n\n## Common Workflows\n\n### Schema Evolution & DDL\n\n1.  Use `gcloud spanner databases ddl update` to apply schema updates (such as CREATE, ALTER, or DROP tables and indexes).\n2.  Reference [schema-design.md](references\/schema-design.md) for guidelines on primary key selection and interleaved tables.\n\n### Diagnosing Performance Issues\n\n1.  Use `SPANNER_SYS` tables to identify slow or resource-intensive queries.\n2.  For example, query `SPANNER_SYS.QUERY_STATS_TOP_HOUR` to find queries with the highest CPU usage.\n\n## Reference Directory\n\n- [Core Concepts](references\/core-concepts.md): Explanation of Spanner internals, architecture, and design.\n- [CLI Usage](references\/cli-usage.md): Essential `gcloud spanner` command-line operations for managing instances and databases.\n- [IAM Security](references\/iam-security.md): Roles, permissions, and data governance best practices for Spanner.\n- [Client Library Usage](references\/client-library-usage.md): Using Google Cloud client libraries for Spanner (Java, Go, Python, Node.js).\n- [Terraform Usage](references\/terraform-usage.md): Infrastructure as Code examples for provisioning Spanner instances and databases.\n- [MCP Usage](references\/mcp-usage.md): Using the Spanner remote MCP server.\n- [PostgreSQL Dialect](references\/postgresql-dialect.md): Best practices and examples for using the PostgreSQL interface in Spanner.\n- [Queues Usage](references\/queues-usage.md): Cloud Spanner Queues: mental model, design constraints, and links related to transactional message queues.\n- [Schema Design](references\/schema-design.md): Guidelines on primary key selection and interleaved tables for performance.\n\nIf you need product information that's not found in these references, use the\n`search_documents` tool of the Developer Knowledge MCP server.\n","use_cases":["Designing primary keys for optimal performance","Applying schema updates using DDL commands","Diagnosing slow queries using SPANNER_SYS tables"],"limitations":[],"compatibility":[],"setup_tip":null,"sample_input":null,"sample_output":null,"source_url":"https:\/\/github.com\/google\/skills\/blob\/e3c591afe426ea585e4c21799e5199d6d47cd1be\/skills\/cloud\/spanner-basics\/SKILL.md","source_commit":"e3c591afe426ea585e4c21799e5199d6d47cd1be","license":null,"version":null,"listing_approved_at":"2026-11-17","created_at":"2026-11-16T19:20:29.000000Z","updated_at":"2026-11-17T17:42:05.000000Z","seo_title":"Spanner Schema Design & DDL Management","seo_description":"Learn how to design efficient schemas, apply schema updates, and diagnose performance issues in Cloud Spanner with this comprehensive guide.","seo_keywords":["Spanner schema design","Cloud Spanner DDL","Spanner performance tuning","Spanner query diagnostics"]}}