Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

spanner-graph-query-tuning

БесплатноБез исполняемых скриптовНе проверен

Tunes and troubleshoots Spanner Graph on Google Cloud ISO GQL queries and execution plans. Use when optimizing slow Spanner Graph GQL queries, diagnosing…

googleот google★ 25 380 звёзд на GitHub

Об этом скилле

Spanner Graph Query Tuning Best Practices

Optimizing ISO GQL queries on Spanner Graph requires aligning pattern matching and path aggregation with Spanner's distributed query execution engine. Small syntactic choices in MATCH and NEXT statements can mean the difference between a targeted index seek (SeekableKeySize: [N]) and a full multi-way cross apply over millions of intermediate paths.

Usage Attribution

MUST READ: Before executing any gcloud, REST API, or MCP command, you MUST read and follow the instructions in Usage Attribution.

Prerequisites & Cloud Environment Setup

Before profiling or executing queries against a Spanner instance (see spanner-basics for general Spanner instance provisioning and MCP setup):

  1. Google Cloud SDK (gcloud) & Static Analysis Fallback: Verify whether the CLI is installed (do not install gcloud without explicit user permission; see Install the Google Cloud SDK). If gcloud or live Spanner database access is unavailable, do not block on executing gcloud spanner databases ddl describe or --query-mode=PROFILE—instead, perform static GQL query analysis and rewrites directly using the user-provided query, DDL, or execution plan and the bundled references/ guides.
  2. Project, Billing & API: Verify an active Google Cloud project with billing enabled (required even when provisioning a free trial instance) is configured (gcloud config set project {project_id}) and, after the user confirms, enable the Spanner API (gcloud services enable spanner.googleapis.com). Ask the user before changing the active project, billing, or enabled APIs, because these commands change the user's Google Cloud environment and can incur costs.
  3. Authentication & Identity and Access Management (IAM) Roles: Authenticate via gcloud auth login or gcloud auth application-default login (or GOOGLE_APPLICATION_CREDENTIALS for service accounts). Inspecting DDL and profiling queries requires roles/spanner.databaseReader (or roles/spanner.databaseUser) on {database_id}.
  4. Instance Region, Pricing & Teardown: For test instances, default to regional-us-central1 unless specified otherwise (see Spanner instance configurations, Google Cloud locations, Spanner pricing, and Google Cloud pricing). After benchmarking on temporary test resources, remind the user to delete temporary test databases (gcloud spanner databases delete {database_id} --instance={instance_id}) or test instances (gcloud spanner instances delete {instance_id}) so they do not incur ongoing Spanner compute and storage charges.

Closed-Loop Query Profiling Workflow

Never apply join or index hints blindly. Always inspect the database DDL, profile the baseline query, apply structural GQL rewrites first, validate compilation with PLAN, and re-profile to verify latency and scanned rows:

  1. Fetch the schema DDL and profile the baseline query using gcloud spanner databases ddl describe and gcloud spanner databases execute-sql with --query-mode=PROFILE (or --query-mode=PLAN if the baseline times out):

    gcloud spanner databases ddl describe {database_id} --instance={instance_id}
    
    gcloud spanner databases execute-sql {database_id} \
      --instance={instance_id} \
      --query-mode=PROFILE \
      --sql="GRAPH MyGraph MATCH ... RETURN ..."
    
  2. Inspect key execution plan metrics (detailed in references/profile-and-hints-guide.md):

    • Join Type: Check whether traversal steps use Distributed Cross Apply (nested-loop index seeks per input row) or Hash Join (set-based scan + build/probe).
    • SeekableKeySize vs. Residual Condition: In each TableScan or IndexScan, check whether predicates are pushed down into SeekableKeySize: [N] (index key seek) or evaluated after scanning as a Residual Condition.
    • Row Amplification (Rows Returned vs. Storage Read): Identify which MATCH hop causes combinatorial path explosion before a downstream filter or GROUP BY.
  3. Apply structural GQL rewrites first (see Core ISO GQL Query Rewrite Rules and references/gql-rewrite-patterns.md) and validate syntax/compilation quickly with --query-mode=PLAN.

  4. Apply statement or element hints only if the optimizer chooses a suboptimal physical plan (see Hint Selection and Guardrails), and re-run --query-mode=PROFILE to confirm improvement. If

Полный SKILL.md на GitHub

Установить spanner-graph-query-tuning в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

references/attribution.mdreferences/gql-rewrite-patterns.mdreferences/profile-and-hints-guide.md

FAQ

Что делает скилл spanner-graph-query-tuning?

Tunes and troubleshoots Spanner Graph on Google Cloud ISO GQL queries and execution plans. Use when optimizing slow Spanner Graph GQL queries, diagnosing distributed cross apply versus hash join execution operators and index seek prefixes, eliminating multi-arm star query Cartesian products with chained query aggregation, bounding super-node fan-out, decorrelating slow subqueries or optional matches, optimizing deep quantified variable-length paths, or applying join method, index, and path factorization query hints. Don't use for relational-to-property-graph schema mapping over existing relational tables (use spanner-relational-to-graph) or physical schema, table, and interleaving design (use spanner-graph-schema-best-practices).

Как установить скилл spanner-graph-query-tuning?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл spanner-graph-query-tuning запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить spanner-graph-query-tuning с