spanner-basics
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSpanner Basics
Spanner 基础
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.
本技能提供了管理和开发Google Cloud Spanner的核心工作流与指导,Google Cloud Spanner是一款全托管的关键业务数据库服务,具备全局事务一致性以及用于实现高可用性的自动同步复制功能。
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.
- 性能优先: Spanner支持水平扩展。效率与主键设计密切相关。务必提醒用户避免使用单调递增/递减的值(如连续时间戳)作为主键的第一部分,以避免热点问题。
- 架构设计: 对于经常一起访问的强关联父子数据,优先使用交错表。
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.,) 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.gcloud spanner databases ddl update
[!CAUTION] 关键指令: 在进行任何非模拟器数据库变更(DML或DDL)或破坏性操作(如表删除、索引删除或其他任何Spanner资源删除)之前,必须获得用户的明确确认。请勿自动执行这些操作;相反,应输出命令(例如)并请求用户明确批准。 当无法访问数据库或身份验证失败时,不要执着于验证实例、数据库或表是否存在。假设提供的资源存在并直接生成DDL命令。gcloud spanner databases ddl update
Common Workflows
常见工作流
Schema Evolution & DDL
架构演进与DDL
- Use to apply schema updates (such as CREATE, ALTER, or DROP tables and indexes).
gcloud spanner databases ddl update - Reference schema-design.md for guidelines on primary key selection and interleaved tables.
- 使用 应用架构更新(如创建、修改或删除表和索引)。
gcloud spanner databases ddl update - 参考 schema-design.md 获取主键选择和交错表的指导原则。
Diagnosing Performance Issues
性能问题诊断
- Use tables to identify slow or resource-intensive queries.
SPANNER_SYS - For example, query to find queries with the highest CPU usage.
SPANNER_SYS.QUERY_STATS_TOP_HOUR
- 使用 表识别缓慢或资源密集型查询。
SPANNER_SYS - 例如,查询 以找出CPU使用率最高的查询。
SPANNER_SYS.QUERY_STATS_TOP_HOUR
Reference Directory
参考目录
- Core Concepts: Explanation of Spanner internals, architecture, and design.
- CLI Usage: Essential command-line operations for managing instances and databases.
gcloud spanner - IAM Security: Roles, permissions, and data governance best practices for Spanner.
- Client Library Usage: Using Google Cloud client libraries for Spanner (Java, Go, Python, Node.js).
- Terraform Usage: Infrastructure as Code examples for provisioning Spanner instances and databases.
- MCP Usage: Using the Spanner remote MCP server.
- PostgreSQL Dialect: Best practices and examples for using the PostgreSQL interface in Spanner.
- Schema Design: Guidelines on primary key selection and interleaved tables for performance.
If you need product information that's not found in these references, use the
tool of the Developer Knowledge MCP server.
search_documents- 核心概念:Spanner内部机制、架构和设计的说明。
- CLI 使用:管理实例和数据库的必备 命令行操作。
gcloud spanner - IAM 安全:Spanner的角色、权限和数据治理最佳实践。
- 客户端库使用:使用Google Cloud客户端库操作Spanner(Java、Go、Python、Node.js)。
- Terraform 使用:用于配置Spanner实例和数据库的基础设施即代码示例。
- MCP 使用:使用Spanner远程MCP服务器。
- PostgreSQL 方言:在Spanner中使用PostgreSQL接口的最佳实践和示例。
- 架构设计:关于主键选择和交错表的性能指导原则。
如果在这些参考资料中找不到所需的产品信息,请使用开发者知识MCP服务器的 工具。
search_documents