spanner-basics

Provisions Spanner instances, designs schemas, and diagnoses query performance issues.

Updated May 11, 2026
One-click install
npx skills add https://github.com/alon3153/upe-social-publisher --skill spanner-basics-alon3153
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: spanner-basics
Source: https://github.com/alon3153/upe-social-publisher/tree/main/.agents/skills/spanner-basics
Command: npx skills add https://github.com/alon3153/upe-social-publisher --skill spanner-basics-alon3153

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Working with Google Cloud Spanner requires careful decisions around primary key design, schema evolution, and performance tuning, and mistakes like hotspotting keys can silently degrade production databases. This Skill guides provisioning, schema design, querying, and troubleshooting so those decisions follow Spanner best practices. ## Core Features & Use Cases - Schema Design Guidance: Prevents hotspots by recommending UUID v4 keys, bit-reversed sequences, key hashing, and interleaved tables for parent-child data. - Provisioning & Administration: Covers instance and database creation via gcloud CLI, Terraform, client libraries (Python, Java, Go, Node.js), and the Spanner MCP server. - Performance Diagnosis: Uses SPANNER_SYS tables such as QUERY_STATS_TOP_HOUR to identify slow or CPU-intensive queries. - Use Case: When designing a new orders table, the Skill warns against a monotonically increasing timestamp as the leading primary key and instead proposes a UUID or composite key, then generates the DDL for review before execution. ## Quick Start Ask the assistant to design a Spanner schema for your tables and generate the DDL commands to create the database. ## Safety Note All non-emulator DDL, DML, and destructive operations require explicit user confirmation before execution.

Frequently Asked Questions about spanner-basics

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I design a primary key in Spanner to avoid hotspots?▼

Avoid monotonically increasing or decreasing values like sequential timestamps as the first part of a primary key. Instead use a UUID v4, a bit-reversed sequence, a hash of the unique key, or place a high-cardinality non-monotonic column first to spread writes across the key space.

How do I create a Spanner instance and database with gcloud?▼

Run gcloud spanner instances create with a config, description, and node count or autoscaling limits, then run gcloud spanner databases create with the instance name. Backups and SQL execution use gcloud spanner backups create and gcloud spanner databases execute-sql.

Does Spanner support the PostgreSQL dialect?▼

Yes, Spanner supports both GoogleSQL and a PostgreSQL dialect, including interleaved tables, TTL, and query hints. However it does not support triggers, SERIAL, transactional DDL, or user-defined types and operators.

How do I find slow queries in Spanner?▼

Query the SPANNER_SYS statistics tables, such as SPANNER_SYS.QUERY_STATS_TOP_HOUR, to identify queries with the highest CPU usage. These built-in introspection tables surface slow or resource-intensive statements for tuning.

When should I use interleaved tables in Spanner?▼

Use interleaved tables for strongly related parent-child data that is frequently accessed together, via INTERLEAVE IN PARENT. Keep interleaving depth minimal even though Spanner supports up to seven levels, since deep hierarchies add overhead.

Can I manage Spanner infrastructure with Terraform?▼

Yes, the Google Cloud Terraform Provider supports google_spanner_instance, google_spanner_database, and IAM resources for both. A typical configuration defines an instance with a config and node count, then a database referencing that instance.