[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7AB7X55SC9YGZS8PA4696MF":3,"skill-same:01M7AB7X55SC9YGZS8PA4696MF":149},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":45,"commitSha":46,"skillDirectory":47,"forksCount":48,"repositoryHtmlUrl":49,"repositoryHomepageUrl":6,"ownerHtmlUrl":50,"ownerBlogUrl":6,"ownerDescription":51,"updatedAt":52,"install":53,"resources":66},"01M7AB7X55SC9YGZS8PA4696MF","redshift-query-troubleshooter",null,"Diagnoses Amazon Redshift query failures through a twelve-category diagnostic tree: WLM queue timeout (queue wait vs execution time), table lock detection (STV_LOCKS, lock contention), COPY command failures (IAM role, data format, delimiter, S3 manifest mismatch), distribution key skew causing data skew, sort key misalignment causing full table scans, nested loop joins (DS_DIST_NONE vs DS_DIST_ALL_INNER), insufficient sort\u002Fdist keys, STL_ERROR messages, connection limits, SSL\u002FTLS certificate issues, query plan analysis (EXPLAIN), vacuum blocked by concurrent writes, and encoding conversion errors. Walks symptoms to a verified root cause with evidence-backed probes; emits ROOT_CAUSE_IDENTIFIED or INSUFFICIENT_DATA.","jhkchan\u002Faws-agent-skills","jhkchan","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F1083902?v=4","01M7A2SVQYP9GQTPTDXP5JKYQ4","Jacky Chan","01M7A2SVS117YWCTZABB75HZR1",4,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fredshift-query-troubleshooter\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: redshift-query-troubleshooter\ndescription: 'Diagnoses Amazon Redshift query failures through a twelve-category diagnostic tree: WLM queue timeout (queue wait vs execution time), table lock detection (STV_LOCKS, lock contention), COPY command failures (IAM role, data format, delimiter, S3 manifest mismatch), distribution key skew causing data skew, sort key misalignment causing full table scans, nested loop joins (DS_DIST_NONE vs DS_DIST_ALL_INNER), insufficient sort\u002Fdist keys, STL_ERROR messages, connection limits, SSL\u002FTLS certificate issues, query plan analysis (EXPLAIN), vacuum blocked by concurrent writes, and encoding conversion errors. Walks symptoms to a verified root cause with evidence-backed probes; emits ROOT_CAUSE_IDENTIFIED or INSUFFICIENT_DATA.'\nlicense: Apache-2.0\ncompatibility: Agent runtime that reads SKILL.md (Claude Code, Cursor, Windsurf, Codex, Gemini). Offline symptom classification works from pasted error messages and query context. Live-account diagnosis uses aws redshift describe-clusters, aws redshift describe-cluster-subnet-groups, aws redshift-data execute-statement \u002F describe-statement, and SQL queries against system tables (STV_LOCKS, STL_ERROR, SVV_QUERY_SUMMARY, STL_QUERY, STL_LOAD_ERRORS, SVV_TABLE_INFO, PG_TABLE_DEF, STV_WLM_QUERY_STATE) via the...\nmetadata:\n  domain: aws-cloudops\n  complexity: high\n  requires_llm: 'true'\n  phase: '2'\n  supports_pipeline: 'true'\n  entry_point: 'false'\n  family: Analytics\n  task_type: troubleshoot\n  skill_class: capability\n  lifecycle_status: active\n  verdict_shape: ROOT_CAUSE_IDENTIFIED | INSUFFICIENT_DATA\n  when_to_use: Diagnosing an Amazon Redshift query failure (WLM queue timeout, table lock contention, COPY command failure, distribution key skew, sort key misalignment, nested loop join, connection limit, SSL\u002FTLS error, vacuum blocked, or encoding conversion error), walking a symptom to the failed config or data-modeling layer with verify and fix commands.\n  when_not_to_use: Amazon RDS\u002FAurora query performance tuning (use RDS-specific tooling), Athena query failures (use athena-query-optimizer), EMR Spark job debugging (use emr-cluster-auditor), application-side ORM query construction (use the application logs and ORM docs), or Redshift Serverless workgroup provisioning (use redshift-specific infrastructure tooling). This skill diagnoses query-time failures; it does not tune cluster sizing or manage resize operations.\n  activation_triggers: Redshift query timeout, WLM queue timeout, Redshift table lock, STV_LOCKS, Redshift COPY command failure, STL_LOAD_ERRORS, distribution key skew, sort key misalignment, full table scan, nested loop join, DS_DIST_ALL_INNER, DS_DIST_NONE, Redshift connection limit, Redshift SSL certificate, Redshift encoding conversion, Redshift vacuum blocked, SVV_QUERY_SUMMARY, STL_ERROR, Redshift query plan, EXPLAIN, S3 COPY manifest mismatch, troubleshoot Redshift query\n  invocation_schema: 'Input: either (a) a symptom description (error message, observed behaviour, \"query times out\", \"COPY fails\", \"query is slow\"), optionally paired with the query text and cluster context, OR (b) a cluster identifier plus query ID or error message for live-account diagnosis. Output: a deterministic TARGET\u002FVERDICT\u002FREASON\u002FLAYER\u002FEVIDENCE\u002FREMEDIATION block where VERDICT ∈ {ROOT_CAUSE_IDENTIFIED, INSUFFICIENT_DATA} and LAYER ∈ {WLM_QUEUE_TIMEOUT, TABLE_LOCK, COPY_IAM_ROLE, COPY_DATA_FORMAT, DIST_KEY_SKEW, SORT_KEY_MISALIGNMENT, NESTED_LOOP_JOIN, CONNECTION_LIMIT, SSL_TLS_ERROR, VACUUM_BLOCKED, ENCODING_CONVERSION, QUERY_PLAN, UNKNOWN}.'\n  invocation_example: '# Minimal valid input (offline symptom classification):\n\n    Symptom: \"Redshift query on sales table takes 45 seconds; EXPLAIN\n\n    shows ds_dist_all_inner and a seq scan. The table uses DISTSTYLE EVEN\n\n    but joins on store_id which is the dist key of the store table.\"\n\n    Cluster: prod-analytics-cluster\n\n    Database: analytics_db\n\n    Query: SELECT s.store_name, sum(sa.amount) FROM store s JOIN sales sa ON s.store_id = sa.store_id GROUP BY s.store_name\n\n    Table sales: DISTSTYLE EVEN, sort key (sale_date)\n\n    Table store: DISTSTYLE KEY (distkey: store_id), sort key (store_id)\n\n    EXPLAIN excerpt: XN Hash Join DS_DIST_ALL_INNER -> XN Seq Scan on sales'\n  version: 0.1.0\n  author: Jacky Chan — AWS Community Builder\n  keywords: Redshift, WLM, WLM queue timeout, table lock, STV_LOCKS, COPY command, distribution key, distribution style, sort key, data skew, nested loop join, DS_DIST_ALL_INNER, full table scan, STL_ERROR, SVV_QUERY_SUMMARY, EXPLAIN, vacuum, connection limit, SSL certificate, encoding conversion, load error, S3 manifest, troubleshooting\n  tags: redshift, analytics, troubleshooting, wlm, distribution-key, sort-key, query-performance, data-warehouse\n---\n\n# Redshift Query Troubleshooter\n\n## Quick start\n\n- **Symptom -> layer map (first plausible match drives the first probe):**\n  Query cancelled after N seconds -> WLM_QUEUE_TIMEOUT; query hangs\n  and never completes -> TABLE_LOCK; COPY fails with error ->\n  COPY_IAM_ROLE \u002F COPY_DATA_FORMAT; query is slow but completes ->\n  DIST_KEY_SKEW \u002F SORT_KEY_MISALIGNMENT \u002F NESTED_LOOP_JOIN; cannot\n  connect -> CONNECTION_LIMIT \u002F SSL_TLS_ERROR; characters garbled or\n  \"character not in repertoire\" -> ENCODING_CONVERSION; VACUUM runs\n  forever -> VACUUM_BLOCKED.\n- **Always verify with a probe, never guess.** Each layer has a\n  diagnostic query or CLI command that proves or disproves it. A\n  ROOT_CAUSE_IDENTIFIED verdict requires positive evidence -- a\n  failing probe that matches the symptom -- not a process of\n  elimination.\n- **Distribution style determines join co-location.** The most common\n  Redshift performance problem is a join between two tables on\n  different distribution styles where the join column is not the\n  dist key on at least one table, forcing a DS_DIST_ALL_INNER\n  (broadcast or redistribute). Always EXPLAIN the query and check\n  the scan type before tuning anything else.\n- **Sort keys enable zone map elimination.** A table with no sort key\n  or a sort key that does not match the query predicate forces a full\n  sequential scan (Seq Scan). With a matching sort key, Redshift uses\n  zone maps to skip entire 1 MB blocks. A 10x scan reduction is\n  common just from adding the right sort key.\n- **WLM queue timeout is NOT execution timeout.** A WLM queue timeout\n  means the query waited too long in the queue (QCU spent) and was\n  cancelled before it started executing. A long-running query that\n  starts but takes too long is a different problem (query plan,\n  distribution, or sort key issue).\n\n## Mindset\n\nA failing or slow Redshift query is usually a data modelling or\nworkload management problem wearing a SQL costume. The SQL is correct\nin the majority of cases; the broken thing is the distribution key,\nsort key, WLM queue assignment, table lock, or COPY configuration.\nTreat the query text as innocent until the distribution style, sort\nkey, query plan, and WLM configuration are proven correct. Senior\ndata engineers do not start by rewriting the SQL; they start with\n`EXPLAIN`, `SVV_QUERY_SUMMARY`, and `SVV_TABLE_INFO`, and only modify\nthe query once the physical design and workload management are\nconfirmed correct.\n\n## Philosophy\n\n> **Moved verbatim** → [references\u002Fadvanced-patterns.md](references\u002Fadvanced-patterns.md) § \"Philosophy — four behaviours\".\n> Load when: reading EXPLAIN scan types, choosing DISTSTYLE, designing sort keys, or diagnosing queue hopping.\n## Quick reference -- symptom triage table\n\n| Symptom phrase \u002F error | Most likely layer | First probe |\n|---|---|---|\n| `Query X cancelled due to queue timeout` | WLM_QUEUE_TIMEOUT | `STL_WLM_QUERY` for queue time vs execution time |\n| Query hangs, never completes | TABLE_LOCK | `STV_LOCKS` for active locks |\n| `COPY ... failed`, `stl_load_errors` | COPY_IAM_ROLE \u002F COPY_DATA_FORMAT | `STL_LOAD_ERRORS` for error detail |\n| Query slow, `DS_DIST_ALL_INNER` in EXPLAIN | DIST_KEY_SKEW | `EXPLAIN` + `SVV_TABLE_INFO` distribution style |\n| Query slow, `Seq Scan` in EXPLAIN | SORT_KEY_MISALIGNMENT | `EXPLAIN` + `SVV_TABLE_INFO` sort key |\n| `Nested Loop` in EXPLAIN | NESTED_LOOP_JOIN | `EXPLAIN` join conditions |\n| `FATAL: too many connections` | CONNECTION_LIMIT | Cluster connection limit vs active connections |\n| `SSL certificate verification failed` | SSL_TLS_ERROR | Cluster parameter group `require_ssl` |\n| `character with byte sequence ... has no equivalent` | ENCODING_CONVERSION | Client encoding vs column encoding |\n| `VACUUM` running for hours | VACUUM_BLOCKED | `SVV_VACUUM_PROGRESS` + concurrent write locks |\n| `stl_error` entries | QUERY_PLAN \u002F ENCODING_CONVERSION | `STL_ERROR` for error code and message |\n\n## Pre-flight: cluster state and gather-info gate\n\nBefore running symptom-specific probes, gather the canonical cluster\nconfiguration and short-circuit on states that mimic query failures.\n\n### Account-wide pre-flight commands\n\n> **Moved verbatim** → [references\u002Fdiagnostic-sql-reference.md](references\u002Fdiagnostic-sql-reference.md) § \"Account-wide pre-flight commands\".\n> Load when: gathering cluster state before symptom-specific probes (stl_query, stl_wlm_query, stv_locks, svv_table_info, stl_load_errors).\n### Query-state short-circuit\n\n> **Moved verbatim** → [references\u002Fdiagnostic-sql-reference.md](references\u002Fdiagnostic-sql-reference.md) § \"Query-state short-circuit\".\n> Load when: classifying aborted\u002Fendtime\u002Felapsed states before picking a branch.\nIf the input is malformed (missing cluster identifier, absent query\ntext or error message, no table context), emit:\n\n> **Moved verbatim** → [references\u002Fworked-examples.md](references\u002Fworked-examples.md) § \"INSUFFICIENT_DATA (malformed input)\".\n> Load when: the input is malformed — missing symptom, cluster id, query text, or table context.\n## Process -- Diagnostic decision tree (apply in symptom order)\n\nThe diagnostic tree is symptom-driven. Pick the entry point based on\nthe observed symptom, then walk the layer-specific probes in order.\n**Never emit ROOT_CAUSE_IDENTIFIED without a failing probe that\nmatches the symptom.**\n\n### Step 0: Non-obvious behaviours that change diagnosis\n\n> **Moved verbatim** → [references\u002Fadvanced-patterns.md](references\u002Fadvanced-patterns.md) § \"Step 0: Non-obvious behaviours\".\n> Load when: before trusting the obvious branch — dist key co-location, DISTSTYLE ALL cost, compound vs interleaved sort keys, queue-wait timeouts, COPY IAM\u002Fmanifest subtleties, STL_LOAD_ERRORS granularity, vacuum locking, nested loops, connection limits, client encoding.\n### Step 1: Symptom entry -- pick the diagnostic branch\n\nMap the symptom to a branch. If none match, go to Step 12\n(INSUFFICIENT_DATA).\n\n| Symptom | Branch |\n|---|---|\n| Query cancelled, WLM timeout message | Step 2 -- WLM queue timeout |\n| Query hangs, never completes | Step 3 -- Table lock |\n| COPY command fails | Step 4 -- COPY failures |\n| Query slow, EXPLAIN shows redistribution | Step 5 -- Distribution key skew |\n| Query slow, EXPLAIN shows Seq Scan | Step 6 -- Sort key misalignment |\n| EXPLAIN shows Nested Loop | Step 7 -- Nested loop join |\n| Cannot connect, too many connections | Step 8 -- Connection limit |\n| SSL\u002FTLS error | Step 9 -- SSL\u002FTLS |\n| VACUUM runs forever | Step 10 -- Vacuum blocked |\n| Encoding\u002Fcharacter error | Step 11 -- Encoding conversion |\n| None of the above | Step 12 -- INSUFFICIENT_DATA |\n\n### Step 2: WLM queue timeout\n\nSymptom: query is cancelled with a message like \"Query X cancelled due\nto queue timeout.\"\n\n> **Moved verbatim** → [references\u002Fdiagnostic-sql-reference.md](references\u002Fdiagnostic-sql-reference.md) + [references\u002Ferror-handling.md](references\u002Ferror-handling.md) § \"Step 2 — WLM queue timeout\".\n> Load when: running the stl_wlm_query \u002F stv_wlm_service_class_config probes and interpreting queue vs execution time (fix list in references\u002Ferror-handling.md).\n\n**Verdict:** ROOT_CAUSE_IDENTIFIED, `LAYER: WLM_QUEUE_TIMEOUT`. Fix:\n\n### Step 3: Table lock detection\n\nSymptom: query hangs indefinitely, never completes or fails.\n\n> **Moved verbatim** → [references\u002Fdiagnostic-sql-reference.md](references\u002Fdiagnostic-sql-reference.md) + [references\u002Ferror-handling.md](references\u002Ferror-handling.md) § \"Step 3 — table lock\".\n> Load when: running the stv_locks + stv_inflight probes (lock patterns and fixes in references\u002Ferror-handling.md).\n\nA lock with `granted = false` means the PID is waiting for a lock held\nby `lock_owner_pid` (which has `granted = true`).\n\n> **Moved verbatim** → [references\u002Ferror-handling.md](references\u002Ferror-handling.md) § \"Step 3 — lock patterns\".\n> Load when: matching a lock pattern to its cause (SELECT vs COPY, deadlock, VACUUM FULL).\n\n**Verdict:** ROOT_CAUSE_IDENTIFIED, `LAYER: TABLE_LOCK`. Fix:\n> **Moved verbatim** → [references\u002Ferror-handling.md](references\u002Ferror-handling.md) § \"Step 3 — TABLE_LOCK fixes\".\n> Load when: fixing TABLE_LOCK — terminate blocking PID, batch COPYs, schedule VACUUM.\n\n### Step 4: COPY command failures\n\nSymptom: `COPY` command fails with a load error or access denied.\n\n#### 4a: Check STL_LOAD_ERRORS\n\n> **Moved verbatim** → [references\u002Fdiagnostic-sql-reference.md](references\u002Fdiagnostic-sql-reference.md) + [references\u002Ferror-handling.md](references\u002Ferror-handling.md) § \"Step 4 — COPY failures\".\n> Load when: probing COPY failures — STL_LOAD_ERRORS detail, IAM role verification, format error table, and manifest checks (fix tables in references\u002Ferror-handling.md).\n\n#### 4b: IAM role \u002F S3 access\n\n\n\n**ROOT_CAUSE_IDENTIFIED** with `LAYER: COPY_IAM_ROLE`. Fix: add\n`s3:GetObject` on the bucket to the cluster's IAM role, or use\nCREDENTIALS with explicit AWS access keys (not recommended).\n\n#### 4c: Data format mismatch\n\n\n**ROOT_CAUSE_IDENTIFIED** with `LAYER: COPY_DATA_FORMAT`. Fix: correct\nthe COPY parameters (DELIMITER, ENCODING, FORMAT, FILLRECORD) based on\nthe `stl_load_errors` detail.\n\n#### 4d: S3 manifest mismatch\n\nIf using `COPY FROM 's3:\u002F\u002Fbucket\u002Fmanifest.json' manifest`:\n\n\n\n### Step 5: Distribution key skew\n\nSymptom: query is slow. EXPLAIN shows `DS_DIST_ALL_INNER` or\n`DS_BCAST_INNER` (broadcast of the inner table).\n\n> **Moved verbatim** → [references\u002Fdiagnostic-sql-reference.md](references\u002Fdiagnostic-sql-reference.md) + [references\u002Fadvanced-patterns.md](references\u002Fadvanced-patterns.md) § \"Step 5 — dist key skew\".\n> Load when: probing distribution styles and per-slice skew (pattern table in references\u002Fadvanced-patterns.md).\n\n\n**Verdict:** ROOT_CAUSE_IDENTIFIED, `LAYER: DIST_KEY_SKEW`. Fix:\n- Change the distribution style to KEY on the join column for both\n  tables (`ALTER TABLE ... ALTER DISTSTYLE KEY (...)`).\n- For small dimension tables (\u003C 2-5M rows), use `DISTSTYLE ALL`.\n- After changing, run ANALYZE to update table statistics.\n\n### Step 6: Sort key misalignment\n\nSymptom: query is slow. EXPLAIN shows `Seq Scan` on a large table\nthat should be using a range-restricted scan.\n\n> **Moved verbatim** → [references\u002Fdiagnostic-sql-reference.md](references\u002Fdiagnostic-sql-reference.md) + [references\u002Fadvanced-patterns.md](references\u002Fadvanced-patterns.md) § \"Step 6 — sort key misalignment\".\n> Load when: probing sortkey1 and pg_table_def (effect table in references\u002Fadvanced-patterns.md).\n\n\n**Verdict:** ROOT_CAUSE_IDENTIFIED, `LAYER: SORT_KEY_MISALIGNMENT`.\nFix: add or change the sort key to match the query's primary filter\ncolumn. For queries filtering on multiple independent columns,\nconsider an interleaved sort key (max 3-4 columns).\n\n\n### Step 7: Nested loop join\n\nSymptom: query is very slow. EXPLAIN shows `XN Nested Loop`.\n\n> **Moved verbatim** → [references\u002Fdiagnostic-sql-reference.md](references\u002Fdiagnostic-sql-reference.md) + [references\u002Fadvanced-patterns.md](references\u002Fadvanced-patterns.md) + [references\u002Ferror-handling.md](references\u002Ferror-handling.md) § \"Step 7 — nested loop join\".\n> Load when: confirming XN Nested Loop (meaning in references\u002Fadvanced-patterns.md, cause table in references\u002Ferror-handling.md).\n\n\n\n**Verdict:** ROOT_CAUSE_IDENTIFIED, `LAYER: NESTED_LOOP_JOIN`. Fix:\nadd the missing join condition, fix the data type mismatch, or\nredesign the query to avoid the Cartesian product.\n\n### Step 8: Connection limit\n\nSymptom: `FATAL: too many connections for \"\u003Cdatabase>\"` or\n`FATAL: remaining connection slots are reserved for non-replication\nsuperuser connections`.\n\n> **Moved verbatim** → [references\u002Fdiagnostic-sql-reference.md](references\u002Fdiagnostic-sql-reference.md) + [references\u002Fadvanced-patterns.md](references\u002Fadvanced-patterns.md) + [references\u002Ferror-handling.md](references\u002Ferror-handling.md) § \"Step 8 — connection limit\".\n> Load when: counting stv_sessions (limit model in references\u002Fadvanced-patterns.md, pattern fixes in references\u002Ferror-handling.md).\n\n\n\n**Verdict:** ROOT_CAUSE_IDENTIFIED, `LAYER: CONNECTION_LIMIT`. Fix:\nimplement connection pooling, reduce idle connections, or scale the\ncluster to a larger node type with more connection capacity.\n\n### Step 9: SSL\u002FTLS certificate issues\n\nSymptom: `SSL certificate verification failed` or\n`FATAL: no pg_hba.conf entry for host ... SSL off`.\n\n> **Moved verbatim** → [references\u002Fdiagnostic-sql-reference.md](references\u002Fdiagnostic-sql-reference.md) + [references\u002Ferror-handling.md](references\u002Ferror-handling.md) § \"Step 9 — SSL\u002FTLS\".\n> Load when: checking require_ssl via parameter group (issue table in references\u002Ferror-handling.md).\n\n\n**Verdict:** ROOT_CAUSE_IDENTIFIED, `LAYER: SSL_TLS_ERROR`. Fix: align\nthe client SSL settings with the cluster's `require_ssl` parameter.\n\n### Step 10: Vacuum blocked\n\nSymptom: `VACUUM` command runs for a very long time without completing.\n\n> **Moved verbatim** → [references\u002Fdiagnostic-sql-reference.md](references\u002Fdiagnostic-sql-reference.md) + [references\u002Ferror-handling.md](references\u002Ferror-handling.md) § \"Step 10 — vacuum blocked\".\n> Load when: checking svv_vacuum_progress, unsorted %, and write locks (issue table in references\u002Ferror-handling.md).\n\n\n**Verdict:** ROOT_CAUSE_IDENTIFIED, `LAYER: VACUUM_BLOCKED`. Fix:\nschedule VACUUM during low-write windows, use VACUUM DELETE ONLY or\nSORT ONLY, or perform a deep copy (create a new table with the right\nsort key and INSERT INTO).\n\n### Step 11: Encoding conversion\n\nSymptom: `ERROR: character with byte sequence 0xXX in encoding \"UTF8\"\nhas no equivalent in encoding \"LATIN1\"` or similar.\n\n> **Moved verbatim** → [references\u002Fdiagnostic-sql-reference.md](references\u002Fdiagnostic-sql-reference.md) + [references\u002Ferror-handling.md](references\u002Ferror-handling.md) § \"Step 11 — encoding conversion\".\n> Load when: checking server\u002Fclient encoding (fix table in references\u002Ferror-handling.md).\n\n\n**Verdict:** ROOT_CAUSE_IDENTIFIED, `LAYER: ENCODING_CONVERSION`.\n\n### Step 12: INSUFFICIENT_DATA\n\nIf none of the above produced a positive root-cause match, emit:\n\n> **Moved verbatim** → [references\u002Fworked-examples.md](references\u002Fworked-examples.md) § \"Step 12 — INSUFFICIENT_DATA template\".\n> Load when: no branch produced a positive root-cause match.\n## Output format\n\n```text\nTARGET: \u003Ccluster-id \u002F query-id>\nVERDICT: ROOT_CAUSE_IDENTIFIED | INSUFFICIENT_DATA\nREASON: \u003C1-2 sentences naming the failed layer and the failing probe>\nLAYER: \u003CWLM_QUEUE_TIMEOUT | TABLE_LOCK | COPY_IAM_ROLE |\n        COPY_DATA_FORMAT | DIST_KEY_SKEW |\n        SORT_KEY_MISALIGNMENT | NESTED_LOOP_JOIN |\n        CONNECTION_LIMIT | SSL_TLS_ERROR | VACUUM_BLOCKED |\n        ENCODING_CONVERSION | QUERY_PLAN | UNKNOWN>\nEVIDENCE:\n  - \u003Cobserved symptom -- error string or behaviour>\n  - \u003Cfailing probe -- query\u002FCLI and its output that confirms the cause>\n  - \u003Cpassing probes -- layers ruled out>\nREMEDIATION:\n  1. \u003Cspecific action with SQL or CLI command>\n  2. \u003Cverification command after the fix>\nCONFIRM: Before executing any state-changing SQL or CLI, emit and\n  await operator approval: \"CONFIRM: About to \u003Caction> on \u003Ccluster>.\n  Proceed? (yes\u002Fno)\"\n```\n\n### Worked example -- distribution key skew (DS_DIST_ALL_INNER)\n\n```text\nTARGET: prod-analytics-cluster, query 12345\nVERDICT: ROOT_CAUSE_IDENTIFIED\nREASON: The query joins sales (DISTSTYLE EVEN) to store (DISTSTYLE\n  KEY on store_id) on the store_id column. EXPLAIN shows\n  DS_DIST_ALL_INNER -- the sales table is redistributed to every\n  node at query time because its distribution does not match the\n  join column. The sales table has 800 million rows; the broadcast\n  cost dominates query time.\nLAYER: DIST_KEY_SKEW\nEVIDENCE:\n  - Symptom: query takes 45 seconds; EXPLAIN shows\n    \"XN Hash Join DS_DIST_ALL_INNER\" followed by \"XN Seq Scan on\n    sales\".\n  - Probe: SVV_TABLE_INFO shows sales.diststyle = EVEN,\n    store.diststyle = KEY(distkey: store_id). The join column\n    (store_id) is not the dist key on sales.\n  - Probe: EXPLAIN confirms DS_DIST_ALL_INNER -- the entire sales\n    table is redistributed to all nodes.\n  - Passing: sales has a sort key on sale_date; the query filters on\n    sale_date (sort key is correct); the query uses a Hash Join (not\n    a Nested Loop); no locks are present (STV_LOCKS empty); WLM\n    queue time is \u003C 1 second.\nREMEDIATION:\n  1. Change the sales table distribution style to KEY(store_id):\n     ALTER TABLE sales ALTER DISTSTYLE KEY (store_id);\n  2. Run ANALYZE to update statistics:\n     ANALYZE sales;\n  3. Re-run the query; EXPLAIN should show DS_DIST_NONE (no\n    redistribution). Expected runtime: \u003C 5 seconds.\nCONFIRM: Before altering the table, emit and await:\n  \"CONFIRM: About to ALTER DISTSTYLE on sales to KEY(store_id).\n   This requires a table rewrite. Proceed? (yes\u002Fno)\"\n```\n\n### Worked example -- WLM queue timeout\n\n> **Moved verbatim** → [references\u002Fworked-examples.md](references\u002Fworked-examples.md) § \"Worked example — WLM queue timeout\".\n> Load when: emitting a ROOT_CAUSE_IDENTIFIED block for a WLM_QUEUE_TIMEOUT diagnosis.\n### Worked example -- COPY data format error\n\n> **Moved verbatim** → [references\u002Fworked-examples.md](references\u002Fworked-examples.md) § \"Worked example — COPY data format error\".\n> Load when: emitting a ROOT_CAUSE_IDENTIFIED block for a COPY_DATA_FORMAT diagnosis.\n## Anti-Patterns -- NEVER\n\n- NEVER declare ROOT_CAUSE_IDENTIFIED without a failing probe that\n  matches the symptom. A \"process of elimination\" diagnosis erodes\n  operator trust when the real cause is elsewhere.\n\n- NEVER rewrite a slow query before running EXPLAIN. The EXPLAIN\n  output's scan type (Seq Scan, DS_DIST_NONE, DS_DIST_ALL_INNER)\n  immediately identifies whether the problem is distribution, sort\n  keys, or join structure. Query rewrites without EXPLAIN are\n  guesswork.\n\n- NEVER use DISTSTYLE ALL on a large table. ALL replicates the entire\n  table to every node. For tables over ~5 million rows, the storage\n  and write-time cost is prohibitive. Use KEY on the join column\n  instead.\n\n- NEVER use DISTSTYLE EVEN for tables that participate in joins on a\n  specific column. EVEN distribution means every join requires a\n  network redistribution (DS_DIST_ALL_INNER). Choose KEY on the\n  dominant join column.\n\n- NEVER assume a compound sort key helps queries on its second column.\n  A compound sort key on `(date, region)` only accelerates queries\n  filtering on `date` or `date AND region`. A query filtering on\n  `region` alone gets NO zone map benefit. Use an interleaved sort\n  key for independent filter columns.\n\n- NEVER ignore the `unsorted` column in SVV_TABLE_INFO. A high\n  unsorted percentage (> 20%) means zone maps are degraded. Run\n  VACUUM SORT to re-sort the table and restore zone map\n  effectiveness.\n\n- NEVER run COPY without checking STL_LOAD_ERRORS first. The first\n  error row (lowest starttime) identifies the root cause -- wrong\n  delimiter, wrong encoding, bad data value. Subsequent errors are\n  often cascading failures from the first bad row.\n\n- NEVER use `mandatory: false` on manifest files in production COPY\n  pipelines without monitoring. Missing files are silently skipped,\n  causing silent data loss. Use `mandatory: true` and alert on COPY\n  failures.\n\n- NEVER confuse WLM queue timeout with execution timeout. A query\n  cancelled at 240s with queue_time = 240s and exec_time = 0s never\n  ran -- it starved in the queue. Adding query slots fixes queue\n  timeout; optimizing the query plan does not.\n\n- NEVER assume a Nested Loop join is intentional. 99% of Nested Loop\n  joins in analytical queries are bugs -- a missing join condition,\n  a data type mismatch, or a join on a UDF output. Always flag\n  Nested Loop joins as suspicious.\n\n- NEVER terminate a blocking PID without confirming with the\n  operator. `pg_terminate_backend` rolls back the target transaction.\n  If the blocking query is a critical ETL load, terminating it may\n  cause data inconsistency.\n\n- NEVER change a table's distribution style during peak hours.\n  `ALTER TABLE ... ALTER DISTSTYLE` requires a full table rewrite.\n  On large tables this can take hours and holds exclusive locks.\n  Schedule during maintenance windows.\n\n- NEVER set the client encoding to a value that does not match the\n  data encoding. UTF8 data loaded with a Latin-1 client encoding\n  causes garbled characters and query failures. Always verify\n  `SHOW client_encoding` matches the data source.\n\n## Pre-flight safety checks (run before any state-changing SQL)\n\n- **MANDATORY CONFIRMATION GATE.** Before any state-changing operation\n  (`ALTER TABLE`, `VACUUM`, `TRUNCATE`, `DROP TABLE`,\n  `pg_terminate_backend`, WLM config update), emit and await operator\n  approval. Do NOT execute until the operator confirms.\n\n- **Read-only first.** Every probe in the diagnostic tree is\n  read-only (`EXPLAIN`, `SELECT FROM stl_*`, `SELECT FROM svv_*`,\n  `SHOW`). Do not perform state-changing operations as diagnostic\n  probes.\n\n- **`ALTER TABLE ... ALTER DISTSTYLE`** requires a full table rewrite.\n  On large tables, this takes hours and holds an exclusive lock.\n  Always schedule during maintenance windows. Verify with EXPLAIN\n  after the rewrite.\n\n- **`ALTER TABLE ... ALTER SORTKEY`** also requires a table rewrite.\n  Same considerations as diststyle change.\n\n- **`VACUUM`** holds locks that can block writes. `VACUUM DELETE ONLY`\n  is lighter than full VACUUM. Always schedule during low-write\n  windows.\n\n- **`pg_terminate_backend(\u003Cpid>)`** rolls back the target transaction.\n  Confirm the PID is not a critical ETL or reporting query before\n  terminating.\n\n- **WLM configuration changes** apply immediately to new queries;\n  currently running queries are not affected. Test changes in a\n  non-prod environment first.\n\n- **Bulk remediation batch limit.** If the diagnosis identifies the\n  same root cause across multiple tables (e.g., all fact tables have\n  EVEN distribution), batch `ALTER TABLE` operations one at a time\n  with verification between each.\n\n## Remediation guidance\n\n> **Moved verbatim** → [references\u002Ferror-handling.md](references\u002Ferror-handling.md) § \"Remediation guidance per layer\".\n> Load when: the root cause is identified — per-layer fix procedures for all eleven layers.\n## Deep reference: Redshift query execution layer model\n\n> **Moved verbatim** → [references\u002Fexplain-scan-reference.md](references\u002Fexplain-scan-reference.md) § \"Symptom→layer matrix and decision guides\".\n> Load when: classifying offline by error string\u002FEXPLAIN signal, or choosing DISTSTYLE \u002F sort key by table and query profile.\n\n\n\n\n## Recent AWS features (2024-2026)\n\n> **Moved verbatim** → [references\u002Fadvanced-patterns.md](references\u002Fadvanced-patterns.md) § \"Recent AWS features (2024-2026)\".\n> Load when: diagnosing on Auto WLM, Serverless, late materialization, AUTO DISTSTYLE\u002FSORTKEY, Data API, or concurrency-scaling clusters.\n## References (load on demand)\n\n- [references\u002Fdiagnostic-sql-reference.md](references\u002Fdiagnostic-sql-reference.md) — per-layer diagnostic SQL\u002FCLI; now also holds the account-wide pre-flight block, the query-state short-circuit, every per-step probe, and the system-table quick reference moved from SKILL.md\n- [references\u002Fexplain-scan-reference.md](references\u002Fexplain-scan-reference.md) — EXPLAIN scan types and decision guides; now also holds the symptom→layer matrix, distribution\u002Fsort decision guides, and WLM queue types moved from SKILL.md\n- [references\u002Fworked-examples.md](references\u002Fworked-examples.md) — secondary worked examples (WLM queue timeout, COPY format error), the Step 12 INSUFFICIENT_DATA template, and the malformed-input output\n- [references\u002Ferror-handling.md](references\u002Ferror-handling.md) — per-step error\u002Fpattern tables, per-layer remediation guidance moved from SKILL.md\n- [references\u002Fadvanced-patterns.md](references\u002Fadvanced-patterns.md) — philosophy, Step 0 non-obvious behaviours, distribution\u002Fsort pattern tables, recent AWS features\n\n## Domain\n\nAWS CloudOps \u002F Amazon Redshift, Query Performance Diagnostics,\nDistribution and Sort Key Design, Workload Management, and COPY\nData Ingestion.\n\n## AWS documentation\n\n- **Amazon Redshift Database Developer Guide -- Tuning query performance** -- https:\u002F\u002Fdocs.aws.amazon.com\u002Fredshift\u002Flatest\u002Fdg\u002Fc-optimizing-query-performance.html\n- **Choosing distribution styles** -- https:\u002F\u002Fdocs.aws.amazon.com\u002Fredshift\u002Flatest\u002Fdg\u002Fc_best-practices-best-distkey.html\n- **Choosing sort keys** -- https:\u002F\u002Fdocs.aws.amazon.com\u002Fredshift\u002Flatest\u002Fdg\u002Fc_best-practices-sort-key.html\n- **EXPLAIN** -- https:\u002F\u002Fdocs.aws.amazon.com\u002Fredshift\u002Flatest\u002Fdg\u002Fr_EXPLAIN.html\n- **WLM query queues** -- https:\u002F\u002Fdocs.aws.amazon.com\u002Fredshift\u002Flatest\u002Fdg\u002Fcm-c-implementing-workload-management.html\n- **COPY command** -- https:\u002F\u002Fdocs.aws.amazon.com\u002Fredshift\u002Flatest\u002Fdg\u002Fr_COPY.html\n- **STL_LOAD_ERRORS** -- https:\u002F\u002Fdocs.aws.amazon.com\u002Fredshift\u002Flatest\u002Fdg\u002Fr_STL_LOAD_ERRORS.html\n- **STV_LOCKS** -- https:\u002F\u002Fdocs.aws.amazon.com\u002Fredshift\u002Flatest\u002Fdg\u002Fr_STV_LOCKS.html\n- **SVV_TABLE_INFO** -- https:\u002F\u002Fdocs.aws.amazon.com\u002Fredshift\u002Flatest\u002Fdg\u002Fr_SVV_TABLE_INFO.html\n- **VACUUM** -- https:\u002F\u002Fdocs.aws.amazon.com\u002Fredshift\u002Flatest\u002Fdg\u002Fr_VACUUM_command.html\n","# Redshift Query Troubleshooter\n\n## Quick start\n\n- **Symptom -> layer map (first plausible match drives the first probe):**\n  Query cancelled after N seconds -> WLM_QUEUE_TIMEOUT; query hangs\n  and never completes -> TABLE_LOCK; COPY fails with error ->\n  COPY_IAM_ROLE \u002F COPY_DATA_FORMAT; query is slow but completes ->\n  DIST_KEY_SKEW \u002F SORT_KEY_MISALIGNMENT \u002F NESTED_LOOP_JOIN; cannot\n  connect -> CONNECTION_LIMIT \u002F SSL_TLS_ERROR; characters garbled or\n  \"character not in repertoire\" -> ENCODING_CONVERSION; VACUUM runs\n  forever -> VACUUM_BLOCKED.\n- **Always verify with a probe, never guess.** Each layer has a\n  diagnostic query or CLI command that proves or disproves it. A\n  ROOT_CAUSE_IDENTIFIED verdict requires positive evidence -- a\n  failing probe that matches the symptom -- not a process of\n  elimination.\n- **Distribution style determines join co-location.** The most common\n  Redshift performance problem is a join between two tables on\n  different distribution styles where the join column is not the\n  dist key on at least one table, forcing a DS_DIST_ALL_INNER\n  (broadcast or redistribute). Always EXPLAIN the query and check\n  the scan type before tuning anything else.\n- **Sort keys enable zone map elimination.** A table with no sort key\n  or a sort key that does not match the query predicate forces a full\n  sequential scan (Seq Scan). With a matching sort key, Redshift uses\n  zone maps to skip entire 1 MB blocks. A 10x scan reduction is\n  common just from adding the right sort key.\n- **WLM queue timeout is NOT execution timeout.** A WLM queue timeout\n  means the query waited too long in the queue (QCU spent) and was\n  cancelled before it started executing. A long-running query that\n  starts but takes too long is a different problem (query plan,\n  distribution, or sort key issue).\n\n## Mindset\n\nA failing or slow Redshift query is usually a data modelling or\nworkload management problem wearing a SQL costume. The SQL is correct\nin the majority of cases; the broken thing is the distribution key,\nsort key, WLM queue assignment, table lock, or COPY configuration.\nTreat the query text as innocent until the distribution style, sort\nkey, query plan, and WLM configuration are proven correct. Senior\ndata engineers do not start by rewriting the SQL; they start with\n`EXPLAIN`, `SVV_QUERY_SUMMARY`, and `SVV_TABLE_INFO`, and only modify\nthe query once the physical design and workload management are\nconfirmed correct.\n\n## Philosophy\n\n> **Moved verbatim** → [references\u002Fadvanced-patterns.md](references\u002Fadvanced-patterns.md) § \"Philosophy — four behaviours\".\n> Load when: reading EXPLAIN scan types, choosing DISTSTYLE, designing sort keys, or diagnosing queue hopping.\n## Quick reference -- symptom triage table\n\n| Symptom phrase \u002F error | Most likely layer | First probe |\n|---|---|---|\n| `Query X cancelled due to queue timeout` | WLM_QUEUE_TIMEOUT | `STL_WLM_QUERY` for queue time vs execution time |\n| Query hangs, never completes | TABLE_LOCK | `STV_LOCKS` for active locks |\n| `COPY ... failed`, `stl_load_errors` | COPY_IAM_ROLE \u002F COPY_DATA_FORMAT | `STL_LOAD_ERRORS` for error detail |\n| Query slow, `DS_DIST_ALL_INNER` in EXPLAIN | DIST_KEY_SKEW | `EXPLAIN` + `SVV_TABLE_INFO` distribution style |\n| Query slow, `Seq Scan` in EXPLAIN | SORT_KEY_MISALIGNMENT | `EXPLAIN` + `SVV_TABLE_INFO` sort key |\n| `Nested Loop` in EXPLAIN | NESTED_LOOP_JOIN | `EXPLAIN` join conditions |\n| `FATAL: too many connections` | CONNECTION_LIMIT | Cluster connection limit vs active connections |\n| `SSL certificate verification failed` | SSL_TLS_ERROR | Cluster parameter group `require_ssl` |\n| `character with byte sequence ... has no equivalent` | ENCODING_CONVERSION | Client encoding vs column encoding |\n| `VACUUM` running for hours | VACUUM_BLOCKED | `SVV_VACUUM_PROGRESS` + concurrent write locks |\n| `stl_error` entries | QUERY_PLAN \u002F ENCODING_CONVERSION | `STL_ERROR` for error code and message |\n\n## Pre-flight: cluster state and gather-info gate\n\nBefore running symptom-specific probes, gather the canonical cluster\nconfiguration and short-circuit on states that mimic query failures.\n\n### Account-wide pre-flight commands\n\n> **Moved verbatim** → [references\u002Fdiagnostic-sql-reference.md](references\u002Fdiagnostic-sql-reference.md) § \"Account-wide pre-flight commands\".\n> Load when: gathering cluster state before symptom-specific probes (stl_query, stl_wlm_query, stv_locks, svv_table_info, stl_load_errors).\n### Query-state short-circuit\n\n> **Moved verbatim** → [references\u002Fdiagnostic-sql-reference.md](references\u002Fdiagnostic-sql-reference.md) § \"Query-state short-circuit\".\n> Load when: classifying aborted\u002Fendtime\u002Felapsed states before picking a branch.\nIf the input is malformed (missing cluster identifier, absent query\ntext or error message, no table context), emit:\n\n> **Moved verbatim** → [references\u002Fworked-examples.md](references\u002Fworked-examples.md) § \"INSUFFICIENT_DATA (malformed input)\".\n> Load when: the input is malformed — missing symptom, cluster id, query text, or table context.\n## Process -- Diagnostic decision tree (apply in symptom order)\n\nThe diagnostic tree is symptom-driven. Pick the entry point based on\nthe observed symptom, then walk the layer-specific probes in order.\n**Never emit ROOT_CAUSE_IDENTIFIED without a failing probe that\nmatches the symptom.**\n\n### Step 0: Non-obvious behaviours that change diagnosis\n\n> **Moved verbatim** → [references\u002Fadvanced-patterns.md](references\u002Fadvanced-patterns.md) § \"Step 0: Non-obvious behaviours\".\n> Load when: before trusting the obvious branch — dist key co-location, DISTSTYLE ALL cost, compound vs interleaved sort keys, queue-wait timeouts, COPY IAM\u002Fmanifest subtleties, STL_LOAD_ERRORS granularity, vacuum locking, nested loops, connection limits, client encoding.\n### Step 1: Symptom entry -- pick the diagnostic branch\n\nMap the symptom to a branch. If none match, go to Step 12\n(INSUFFICIENT_DATA).\n\n| Symptom | Branch |\n|---|---|\n| Query cancelled, WLM timeout message | Step 2 -- WLM queue timeout |\n| Query hangs, never completes | Step 3 -- Table lock |\n| COPY command fails | Step 4 -- COPY failures |\n| Query slow, EXPLAIN shows redistribution | Step 5 -- Distribution key skew |\n| Query slow, EXPLAIN shows Seq Scan | Step 6 -- Sort key misalignment |\n| EXPLAIN shows Nested Loop | Step 7 -- Nested loop join |\n| Cannot connect, too many connections | Step 8 -- Connection limit |\n| SSL\u002FTLS error | Step 9 -- SSL\u002FTLS |\n| VACUUM runs forever | Step 10 -- Vacuum blocked |\n| Encoding\u002Fcharacter error | Step 11 -- Encoding conversion |\n| None of the above | Step 12 -- INSUFFICIENT_DATA |\n\n### Step 2: WLM queue timeout\n\nSymptom: query is cancelled with a message like \"Query X cancelled due\nto queue timeout.\"\n\n> **Moved verbatim** → [references\u002Fdiagnostic-sql-reference.md](references\u002Fdiagnostic-sql-reference.md) + [references\u002Ferror-handling.md](references\u002Ferror-handling.md) § \"Step 2 — WLM queue timeout\".\n> Load when: running the stl_wlm_query \u002F stv_wlm_service_class_config probes and interpreting queue vs execution time (fix list in references\u002Ferror-handling.md).\n\n**Verdict:** ROOT_CAUSE_IDENTIFIED, `LAYER: WLM_QUEUE_TIMEOUT`. Fix:\n\n### Step 3: Table lock detection\n\nSymptom: query hangs indefinitely, never completes or fails.\n\n> **Moved verbatim** → [references\u002Fdiagnostic-sql-reference.md](references\u002Fdiagnostic-sql-reference.md) + [references\u002Ferror-handling.md](references\u002Ferror-handling.md) § \"Step 3 — table lock\".\n> Load when: running the stv_locks + stv_inflight probes (lock patterns and fixes in references\u002Ferror-handling.md).\n\nA lock with `granted = false` means the PID is waiting for a lock held\nby `lock_owner_pid` (which has `granted = true`).\n\n> **Moved verbatim** → [references\u002Ferror-handling.md](references\u002Ferror-handling.md) § \"Step 3 — lock patterns\".\n> Load when: matching a lock pattern to its cause (SELECT vs COPY, deadlock, VACUUM FULL).\n\n**Verdict:** ROOT_CAUSE_IDENTIFIED, `LAYER: TABLE_LOCK`. Fix:\n> **Moved verbatim** → [references\u002Ferror-handling.md](references\u002Ferror-handling.md) § \"Step 3 — TABLE_LOCK fixes\".\n> Load when: fixing TABLE_LOCK — terminate blocking PID, batch COPYs, schedule VACUUM.\n\n### Step 4: COPY command failures\n\nSymptom: `COPY` command fails with a load error or access denied.\n\n#### 4a: Check STL_LOAD_ERRORS\n\n> **Moved verbatim** → [references\u002Fdiagnostic-sql-reference.md](references\u002Fdiagnostic-sql-reference.md) + [references\u002Ferror-handling.md](references\u002Ferror-handling.md) § \"Step 4 — COPY failures\".\n> Load when: probing COPY failures — STL_LOAD_ERRORS detail, IAM role verification, format error table, and manifest checks (fix tables in references\u002Ferror-handling.md).\n\n#### 4b: IAM role \u002F S3 access\n\n\n\n**ROOT_CAUSE_IDENTIFIED** with `LAYER: COPY_IAM_ROLE`. Fix: add\n`s3:GetObject` on the bucket to the cluster's IAM role, or use\nCREDENTIALS with explicit AWS access keys (not recommended).\n\n#### 4c: Data format mismatch\n\n\n**ROOT_CAUSE_IDENTIFIED** with `LAYER: COPY_DATA_FORMAT`. Fix: correct\nthe COPY parameters (DELIMITER, ENCODING, FORMAT, FILLRECORD) based on\nthe `stl_load_errors` detail.\n\n#### 4d: S3 manifest mismatch\n\nIf using `COPY FROM 's3:\u002F\u002Fbucket\u002Fmanifest.json' manifest`:\n\n\n\n### Step 5: Distribution key skew\n\nSymptom: query is slow. EXPLAIN shows `DS_DIST_ALL_INNER` or\n`DS_BCAST_INNER` (broadcast of the inner table).\n\n> **Moved verbatim** → [references\u002Fdiagnostic-sql-reference.md](references\u002Fdiagnostic-sql-reference.md) + [references\u002Fadvanced-patterns.md](references\u002Fadvanced-patterns.md) § \"Step 5 — dist key skew\".\n> Load when: probing distribution styles and per-slice skew (pattern table in references\u002Fadvanced-patterns.md).\n\n\n**Verdict:** ROOT_CAUSE_IDENTIFIED, `LAYER: DIST_KEY_SKEW`. Fix:\n- Change the distribution style to KEY on the join column for both\n  tables (`ALTER TABLE ... ALTER DISTSTYLE KEY (...)`).\n- For small dimension tables (\u003C 2-5M rows), use `DISTSTYLE ALL`.\n- After changing, run ANALYZE to update table statistics.\n\n### Step 6: Sort key misalignment\n\nSymptom: query is slow. EXPLAIN shows `Seq Scan` on a large table\nthat should be using a range-restricted scan.\n\n> **Moved verbatim** → [references\u002Fdiagnostic-sql-reference.md](references\u002Fdiagnostic-sql-reference.md) + [references\u002Fadvanced-patterns.md](references\u002Fadvanced-patterns.md) § \"Step 6 — sort key misalignment\".\n> Load when: probing sortkey1 and pg_table_def (effect table in references\u002Fadvanced-patterns.md).\n\n\n**Verdict:** ROOT_CAUSE_IDENTIFIED, `LAYER: SORT_KEY_MISALIGNMENT`.\nFix: add or change the sort key to match the query's primary filter\ncolumn. For queries filtering on multiple independent columns,\nconsider an interleaved sort key (max 3-4 columns).\n\n\n### Step 7: Nested loop join\n\nSymptom: query is very slow. EXPLAIN shows `XN Nested Loop`.\n\n> **Moved verbatim** → [references\u002Fdiagnostic-sql-reference.md](references\u002Fdiagnostic-sql-reference.md) + [references\u002Fadvanced-patterns.md](references\u002Fadvanced-patterns.md) + [references\u002Ferror-handling.md](references\u002Ferror-handling.md) § \"Step 7 — nested loop join\".\n> Load when: confirming XN Nested Loop (meaning in references\u002Fadvanced-patterns.md, cause table in references\u002Ferror-handling.md).\n\n\n\n**Verdict:** ROOT_CAUSE_IDENTIFIED, `LAYER: NESTED_LOOP_JOIN`. Fix:\nadd the missing join condition, fix the data type mismatch, or\nredesign the query to avoid the Cartesian product.\n\n### Step 8: Connection limit\n\nSymptom: `FATAL: too many connections for \"\u003Cdatabase>\"` or\n`FATAL: remaining connection slots are reserved for non-replication\nsuperuser connections`.\n\n> **Moved verbatim** → [references\u002Fdiagnostic-sql-reference.md](references\u002Fdiagnostic-sql-reference.md) + [references\u002Fadvanced-patterns.md](references\u002Fadvanced-patterns.md) + [references\u002Ferror-handling.md](references\u002Ferror-handling.md) § \"Step 8 — connection limit\".\n> Load when: counting stv_sessions (limit model in references\u002Fadvanced-patterns.md, pattern fixes in references\u002Ferror-handling.md).\n\n\n\n**Verdict:** ROOT_CAUSE_IDENTIFIED, `LAYER: CONNECTION_LIMIT`. Fix:\nimplement connection pooling, reduce idle connections, or scale the\ncluster to a larger node type with more connection capacity.\n\n### Step 9: SSL\u002FTLS certificate issues\n\nSymptom: `SSL certificate verification failed` or\n`FATAL: no pg_hba.conf entry for host ... SSL off`.\n\n> **Moved verbatim** → [references\u002Fdiagnostic-sql-reference.md](references\u002Fdiagnostic-sql-reference.md) + [references\u002Ferror-handling.md](references\u002Ferror-handling.md) § \"Step 9 — SSL\u002FTLS\".\n> Load when: checking require_ssl via parameter group (issue table in references\u002Ferror-handling.md).\n\n\n**Verdict:** ROOT_CAUSE_IDENTIFIED, `LAYER: SSL_TLS_ERROR`. Fix: align\nthe client SSL settings with the cluster's `require_ssl` parameter.\n\n### Step 10: Vacuum blocked\n\nSymptom: `VACUUM` command runs for a very long time without completing.\n\n> **Moved verbatim** → [references\u002Fdiagnostic-sql-reference.md](references\u002Fdiagnostic-sql-reference.md) + [references\u002Ferror-handling.md](references\u002Ferror-handling.md) § \"Step 10 — vacuum blocked\".\n> Load when: checking svv_vacuum_progress, unsorted %, and write locks (issue table in references\u002Ferror-handling.md).\n\n\n**Verdict:** ROOT_CAUSE_IDENTIFIED, `LAYER: VACUUM_BLOCKED`. Fix:\nschedule VACUUM during low-write windows, use VACUUM DELETE ONLY or\nSORT ONLY, or perform a deep copy (create a new table with the right\nsort key and INSERT INTO).\n\n### Step 11: Encoding conversion\n\nSymptom: `ERROR: character with byte sequence 0xXX in encoding \"UTF8\"\nhas no equivalent in encoding \"LATIN1\"` or similar.\n\n> **Moved verbatim** → [references\u002Fdiagnostic-sql-reference.md](references\u002Fdiagnostic-sql-reference.md) + [references\u002Ferror-handling.md](references\u002Ferror-handling.md) § \"Step 11 — encoding conversion\".\n> Load when: checking server\u002Fclient encoding (fix table in references\u002Ferror-handling.md).\n\n\n**Verdict:** ROOT_CAUSE_IDENTIFIED, `LAYER: ENCODING_CONVERSION`.\n\n### Step 12: INSUFFICIENT_DATA\n\nIf none of the above produced a positive root-cause match, emit:\n\n> **Moved verbatim** → [references\u002Fworked-examples.md](references\u002Fworked-examples.md) § \"Step 12 — INSUFFICIENT_DATA template\".\n> Load when: no branch produced a positive root-cause match.\n## Output format\n\n```text\nTARGET: \u003Ccluster-id \u002F query-id>\nVERDICT: ROOT_CAUSE_IDENTIFIED | INSUFFICIENT_DATA\nREASON: \u003C1-2 sentences naming the failed layer and the failing probe>\nLAYER: \u003CWLM_QUEUE_TIMEOUT | TABLE_LOCK | COPY_IAM_ROLE |\n        COPY_DATA_FORMAT | DIST_KEY_SKEW |\n        SORT_KEY_MISALIGNMENT | NESTED_LOOP_JOIN |\n        CONNECTION_LIMIT | SSL_TLS_ERROR | VACUUM_BLOCKED |\n        ENCODING_CONVERSION | QUERY_PLAN | UNKNOWN>\nEVIDENCE:\n  - \u003Cobserved symptom -- error string or behaviour>\n  - \u003Cfailing probe -- query\u002FCLI and its output that confirms the cause>\n  - \u003Cpassing probes -- layers ruled out>\nREMEDIATION:\n  1. \u003Cspecific action with SQL or CLI command>\n  2. \u003Cverification command after the fix>\nCONFIRM: Before executing any state-changing SQL or CLI, emit and\n  await operator approval: \"CONFIRM: About to \u003Caction> on \u003Ccluster>.\n  Proceed? (yes\u002Fno)\"\n```\n\n### Worked example -- distribution key skew (DS_DIST_ALL_INNER)\n\n```text\nTARGET: prod-analytics-cluster, query 12345\nVERDICT: ROOT_CAUSE_IDENTIFIED\nREASON: The query joins sales (DISTSTYLE EVEN) to store (DISTSTYLE\n  KEY on store_id) on the store_id column. EXPLAIN shows\n  DS_DIST_ALL_INNER -- the sales table is redistributed to every\n  node at query time because its distribution does not match the\n  join column. The sales table has 800 million rows; the broadcast\n  cost dominates query time.\nLAYER: DIST_KEY_SKEW\nEVIDENCE:\n  - Symptom: query takes 45 seconds; EXPLAIN shows\n    \"XN Hash Join DS_DIST_ALL_INNER\" followed by \"XN Seq Scan on\n    sales\".\n  - Probe: SVV_TABLE_INFO shows sales.diststyle = EVEN,\n    store.diststyle = KEY(distkey: store_id). The join column\n    (store_id) is not the dist key on sales.\n  - Probe: EXPLAIN confirms DS_DIST_ALL_INNER -- the entire sales\n    table is redistributed to all nodes.\n  - Passing: sales has a sort key on sale_date; the query filters on\n    sale_date (sort key is correct); the query uses a Hash Join (not\n    a Nested Loop); no locks are present (STV_LOCKS empty); WLM\n    queue time is \u003C 1 second.\nREMEDIATION:\n  1. Change the sales table distribution style to KEY(store_id):\n     ALTER TABLE sales ALTER DISTSTYLE KEY (store_id);\n  2. Run ANALYZE to update statistics:\n     ANALYZE sales;\n  3. Re-run the query; EXPLAIN should show DS_DIST_NONE (no\n    redistribution). Expected runtime: \u003C 5 seconds.\nCONFIRM: Before altering the table, emit and await:\n  \"CONFIRM: About to ALTER DISTSTYLE on sales to KEY(store_id).\n   This requires a table rewrite. Proceed? (yes\u002Fno)\"\n```\n\n### Worked example -- WLM queue timeout\n\n> **Moved verbatim** → [references\u002Fworked-examples.md](references\u002Fworked-examples.md) § \"Worked example — WLM queue timeout\".\n> Load when: emitting a ROOT_CAUSE_IDENTIFIED block for a WLM_QUEUE_TIMEOUT diagnosis.\n### Worked example -- COPY data format error\n\n> **Moved verbatim** → [references\u002Fworked-examples.md](references\u002Fworked-examples.md) § \"Worked example — COPY data format error\".\n> Load when: emitting a ROOT_CAUSE_IDENTIFIED block for a COPY_DATA_FORMAT diagnosis.\n## Anti-Patterns -- NEVER\n\n- NEVER declare ROOT_CAUSE_IDENTIFIED without a failing probe that\n  matches the symptom. A \"process of elimination\" diagnosis erodes\n  operator trust when the real cause is elsewhere.\n\n- NEVER rewrite a slow query before running EXPLAIN. The EXPLAIN\n  output's scan type (Seq Scan, DS_DIST_NONE, DS_DIST_ALL_INNER)\n  immediately identifies whether the problem is distribution, sort\n  keys, or join structure. Query rewrites without EXPLAIN are\n  guesswork.\n\n- NEVER use DISTSTYLE ALL on a large table. ALL replicates the entire\n  table to every node. For tables over ~5 million rows, the storage\n  and write-time cost is prohibitive. Use KEY on the join column\n  instead.\n\n- NEVER use DISTSTYLE EVEN for tables that participate in joins on a\n  specific column. EVEN distribution means every join requires a\n  network redistribution (DS_DIST_ALL_INNER). Choose KEY on the\n  dominant join column.\n\n- NEVER assume a compound sort key helps queries on its second column.\n  A compound sort key on `(date, region)` only accelerates queries\n  filtering on `date` or `date AND region`. A query filtering on\n  `region` alone gets NO zone map benefit. Use an interleaved sort\n  key for independent filter columns.\n\n- NEVER ignore the `unsorted` column in SVV_TABLE_INFO. A high\n  unsorted percentage (> 20%) means zone maps are degraded. Run\n  VACUUM SORT to re-sort the table and restore zone map\n  effectiveness.\n\n- NEVER run COPY without checking STL_LOAD_ERRORS first. The first\n  error row (lowest starttime) identifies the root cause -- wrong\n  delimiter, wrong encoding, bad data value. Subsequent errors are\n  often cascading failures from the first bad row.\n\n- NEVER use `mandatory: false` on manifest files in production COPY\n  pipelines without monitoring. Missing files are silently skipped,\n  causing silent data loss. Use `mandatory: true` and alert on COPY\n  failures.\n\n- NEVER confuse WLM queue timeout with execution timeout. A query\n  cancelled at 240s with queue_time = 240s and exec_time = 0s never\n  ran -- it starved in the queue. Adding query slots fixes queue\n  timeout; optimizing the query plan does not.\n\n- NEVER assume a Nested Loop join is intentional. 99% of Nested Loop\n  joins in analytical queries are bugs -- a missing join condition,\n  a data type mismatch, or a join on a UDF output. Always flag\n  Nested Loop joins as suspicious.\n\n- NEVER terminate a blocking PID without confirming with the\n  operator. `pg_terminate_backend` rolls back the target transaction.\n  If the blocking query is a critical ETL load, terminating it may\n  cause data inconsistency.\n\n- NEVER change a table's distribution style during peak hours.\n  `ALTER TABLE ... ALTER DISTSTYLE` requires a full table rewrite.\n  On large tables this can take hours and holds exclusive locks.\n  Schedule during maintenance windows.\n\n- NEVER set the client encoding to a value that does not match the\n  data encoding. UTF8 data loaded with a Latin-1 client encoding\n  causes garbled characters and query failures. Always verify\n  `SHOW client_encoding` matches the data source.\n\n## Pre-flight safety checks (run before any state-changing SQL)\n\n- **MANDATORY CONFIRMATION GATE.** Before any state-changing operation\n  (`ALTER TABLE`, `VACUUM`, `TRUNCATE`, `DROP TABLE`,\n  `pg_terminate_backend`, WLM config update), emit and await operator\n  approval. Do NOT execute until the operator confirms.\n\n- **Read-only first.** Every probe in the diagnostic tree is\n  read-only (`EXPLAIN`, `SELECT FROM stl_*`, `SELECT FROM svv_*`,\n  `SHOW`). Do not perform state-changing operations as diagnostic\n  probes.\n\n- **`ALTER TABLE ... ALTER DISTSTYLE`** requires a full table rewrite.\n  On large tables, this takes hours and holds an exclusive lock.\n  Always schedule during maintenance windows. Verify with EXPLAIN\n  after the rewrite.\n\n- **`ALTER TABLE ... ALTER SORTKEY`** also requires a table rewrite.\n  Same considerations as diststyle change.\n\n- **`VACUUM`** holds locks that can block writes. `VACUUM DELETE ONLY`\n  is lighter than full VACUUM. Always schedule during low-write\n  windows.\n\n- **`pg_terminate_backend(\u003Cpid>)`** rolls back the target transaction.\n  Confirm the PID is not a critical ETL or reporting query before\n  terminating.\n\n- **WLM configuration changes** apply immediately to new queries;\n  currently running queries are not affected. Test changes in a\n  non-prod environment first.\n\n- **Bulk remediation batch limit.** If the diagnosis identifies the\n  same root cause across multiple tables (e.g., all fact tables have\n  EVEN distribution), batch `ALTER TABLE` operations one at a time\n  with verification between each.\n\n## Remediation guidance\n\n> **Moved verbatim** → [references\u002Ferror-handling.md](references\u002Ferror-handling.md) § \"Remediation guidance per layer\".\n> Load when: the root cause is identified — per-layer fix procedures for all eleven layers.\n## Deep reference: Redshift query execution layer model\n\n> **Moved verbatim** → [references\u002Fexplain-scan-reference.md](references\u002Fexplain-scan-reference.md) § \"Symptom→layer matrix and decision guides\".\n> Load when: classifying offline by error string\u002FEXPLAIN signal, or choosing DISTSTYLE \u002F sort key by table and query profile.\n\n\n\n\n## Recent AWS features (2024-2026)\n\n> **Moved verbatim** → [references\u002Fadvanced-patterns.md](references\u002Fadvanced-patterns.md) § \"Recent AWS features (2024-2026)\".\n> Load when: diagnosing on Auto WLM, Serverless, late materialization, AUTO DISTSTYLE\u002FSORTKEY, Data API, or concurrency-scaling clusters.\n## References (load on demand)\n\n- [references\u002Fdiagnostic-sql-reference.md](references\u002Fdiagnostic-sql-reference.md) — per-layer diagnostic SQL\u002FCLI; now also holds the account-wide pre-flight block, the query-state short-circuit, every per-step probe, and the system-table quick reference moved from SKILL.md\n- [references\u002Fexplain-scan-reference.md](references\u002Fexplain-scan-reference.md) — EXPLAIN scan types and decision guides; now also holds the symptom→layer matrix, distribution\u002Fsort decision guides, and WLM queue types moved from SKILL.md\n- [references\u002Fworked-examples.md](references\u002Fworked-examples.md) — secondary worked examples (WLM queue timeout, COPY format error), the Step 12 INSUFFICIENT_DATA template, and the malformed-input output\n- [references\u002Ferror-handling.md](references\u002Ferror-handling.md) — per-step error\u002Fpattern tables, per-layer remediation guidance moved from SKILL.md\n- [references\u002Fadvanced-patterns.md](references\u002Fadvanced-patterns.md) — philosophy, Step 0 non-obvious behaviours, distribution\u002Fsort pattern tables, recent AWS features\n\n## Domain\n\nAWS CloudOps \u002F Amazon Redshift, Query Performance Diagnostics,\nDistribution and Sort Key Design, Workload Management, and COPY\nData Ingestion.\n\n## AWS documentation\n\n- **Amazon Redshift Database Developer Guide -- Tuning query performance** -- https:\u002F\u002Fdocs.aws.amazon.com\u002Fredshift\u002Flatest\u002Fdg\u002Fc-optimizing-query-performance.html\n- **Choosing distribution styles** -- https:\u002F\u002Fdocs.aws.amazon.com\u002Fredshift\u002Flatest\u002Fdg\u002Fc_best-practices-best-distkey.html\n- **Choosing sort keys** -- https:\u002F\u002Fdocs.aws.amazon.com\u002Fredshift\u002Flatest\u002Fdg\u002Fc_best-practices-sort-key.html\n- **EXPLAIN** -- https:\u002F\u002Fdocs.aws.amazon.com\u002Fredshift\u002Flatest\u002Fdg\u002Fr_EXPLAIN.html\n- **WLM query queues** -- https:\u002F\u002Fdocs.aws.amazon.com\u002Fredshift\u002Flatest\u002Fdg\u002Fcm-c-implementing-workload-management.html\n- **COPY command** -- https:\u002F\u002Fdocs.aws.amazon.com\u002Fredshift\u002Flatest\u002Fdg\u002Fr_COPY.html\n- **STL_LOAD_ERRORS** -- https:\u002F\u002Fdocs.aws.amazon.com\u002Fredshift\u002Flatest\u002Fdg\u002Fr_STL_LOAD_ERRORS.html\n- **STV_LOCKS** -- https:\u002F\u002Fdocs.aws.amazon.com\u002Fredshift\u002Flatest\u002Fdg\u002Fr_STV_LOCKS.html\n- **SVV_TABLE_INFO** -- https:\u002F\u002Fdocs.aws.amazon.com\u002Fredshift\u002Flatest\u002Fdg\u002Fr_SVV_TABLE_INFO.html\n- **VACUUM** -- https:\u002F\u002Fdocs.aws.amazon.com\u002Fredshift\u002Flatest\u002Fdg\u002Fr_VACUUM_command.html\n",{"name":5,"license":15,"metadata":24,"description":7,"compatibility":44},{"tags":25,"phase":26,"author":27,"domain":28,"family":29,"version":30,"keywords":31,"task_type":32,"complexity":33,"entry_point":34,"skill_class":35,"when_to_use":36,"requires_llm":37,"verdict_shape":38,"when_not_to_use":39,"lifecycle_status":40,"invocation_schema":41,"supports_pipeline":37,"invocation_example":42,"activation_triggers":43},"redshift, analytics, troubleshooting, wlm, distribution-key, sort-key, query-performance, data-warehouse","2","Jacky Chan — AWS Community Builder","aws-cloudops","Analytics","0.1.0","Redshift, WLM, WLM queue timeout, table lock, STV_LOCKS, COPY command, distribution key, distribution style, sort key, data skew, nested loop join, DS_DIST_ALL_INNER, full table scan, STL_ERROR, SVV_QUERY_SUMMARY, EXPLAIN, vacuum, connection limit, SSL certificate, encoding conversion, load error, S3 manifest, troubleshooting","troubleshoot","high","false","capability","Diagnosing an Amazon Redshift query failure (WLM queue timeout, table lock contention, COPY command failure, distribution key skew, sort key misalignment, nested loop join, connection limit, SSL\u002FTLS error, vacuum blocked, or encoding conversion error), walking a symptom to the failed config or data-modeling layer with verify and fix commands.","true","ROOT_CAUSE_IDENTIFIED | INSUFFICIENT_DATA","Amazon RDS\u002FAurora query performance tuning (use RDS-specific tooling), Athena query failures (use athena-query-optimizer), EMR Spark job debugging (use emr-cluster-auditor), application-side ORM query construction (use the application logs and ORM docs), or Redshift Serverless workgroup provisioning (use redshift-specific infrastructure tooling). This skill diagnoses query-time failures; it does not tune cluster sizing or manage resize operations.","active","Input: either (a) a symptom description (error message, observed behaviour, \"query times out\", \"COPY fails\", \"query is slow\"), optionally paired with the query text and cluster context, OR (b) a cluster identifier plus query ID or error message for live-account diagnosis. Output: a deterministic TARGET\u002FVERDICT\u002FREASON\u002FLAYER\u002FEVIDENCE\u002FREMEDIATION block where VERDICT ∈ {ROOT_CAUSE_IDENTIFIED, INSUFFICIENT_DATA} and LAYER ∈ {WLM_QUEUE_TIMEOUT, TABLE_LOCK, COPY_IAM_ROLE, COPY_DATA_FORMAT, DIST_KEY_SKEW, SORT_KEY_MISALIGNMENT, NESTED_LOOP_JOIN, CONNECTION_LIMIT, SSL_TLS_ERROR, VACUUM_BLOCKED, ENCODING_CONVERSION, QUERY_PLAN, UNKNOWN}.","# Minimal valid input (offline symptom classification):\nSymptom: \"Redshift query on sales table takes 45 seconds; EXPLAIN\nshows ds_dist_all_inner and a seq scan. The table uses DISTSTYLE EVEN\nbut joins on store_id which is the dist key of the store table.\"\nCluster: prod-analytics-cluster\nDatabase: analytics_db\nQuery: SELECT s.store_name, sum(sa.amount) FROM store s JOIN sales sa ON s.store_id = sa.store_id GROUP BY s.store_name\nTable sales: DISTSTYLE EVEN, sort key (sale_date)\nTable store: DISTSTYLE KEY (distkey: store_id), sort key (store_id)\nEXPLAIN excerpt: XN Hash Join DS_DIST_ALL_INNER -> XN Seq Scan on sales","Redshift query timeout, WLM queue timeout, Redshift table lock, STV_LOCKS, Redshift COPY command failure, STL_LOAD_ERRORS, distribution key skew, sort key misalignment, full table scan, nested loop join, DS_DIST_ALL_INNER, DS_DIST_NONE, Redshift connection limit, Redshift SSL certificate, Redshift encoding conversion, Redshift vacuum blocked, SVV_QUERY_SUMMARY, STL_ERROR, Redshift query plan, EXPLAIN, S3 COPY manifest mismatch, troubleshoot Redshift query","Agent runtime that reads SKILL.md (Claude Code, Cursor, Windsurf, Codex, Gemini). Offline symptom classification works from pasted error messages and query context. Live-account diagnosis uses aws redshift describe-clusters, aws redshift describe-cluster-subnet-groups, aws redshift-data execute-statement \u002F describe-statement, and SQL queries against system tables (STV_LOCKS, STL_ERROR, SVV_QUERY_SUMMARY, STL_QUERY, STL_LOAD_ERRORS, SVV_TABLE_INFO, PG_TABLE_DEF, STV_WLM_QUERY_STATE) via the...","main","eeace51bd5dd1db2030729d83eeab988861553aa","skills\u002Fredshift-query-troubleshooter",0,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills","https:\u002F\u002Fgithub.com\u002Fjhkchan","CTO & Co-Founder @Beever-AI  & @votee. CAISP. AWS Community Builder. Organizer@GDGCloudHK. MongoDB Champion. Technopreneur + Infornographer.","2026-09-24 08:54:10",{"source":8,"skillName":5,"commands":54,"prompt":64,"zipAvailable":65},[55,58,61],{"tool":56,"command":57},"npx","npx skills add jhkchan\u002Faws-agent-skills --skill redshift-query-troubleshooter",{"tool":59,"command":60},"bunx","bunx skills add jhkchan\u002Faws-agent-skills --skill redshift-query-troubleshooter",{"tool":62,"command":63},"pnpm","pnpm dlx skills add jhkchan\u002Faws-agent-skills --skill redshift-query-troubleshooter","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fredshift-query-troubleshooter\u002FSKILL.md",true,[67,73,77,81,85,89,93,97,101,105,109,113,117,121,125,129,133,137,141,145],{"path":68,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":71,"sourceHtmlUrl":72},"eval\u002Ftest-cases.yaml","REFERENCE","参考文档",9675,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fredshift-query-troubleshooter\u002Feval\u002Ftest-cases.yaml",{"path":74,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":75,"sourceHtmlUrl":76},"evals\u002Fbaselines\u002Fcopy-data-format-delimiter.md",548,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fredshift-query-troubleshooter\u002Fevals\u002Fbaselines\u002Fcopy-data-format-delimiter.md",{"path":78,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":79,"sourceHtmlUrl":80},"evals\u002Fbaselines\u002Fdistkey-skew-ds-dist-all-inner.md",898,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fredshift-query-troubleshooter\u002Fevals\u002Fbaselines\u002Fdistkey-skew-ds-dist-all-inner.md",{"path":82,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":83,"sourceHtmlUrl":84},"evals\u002Fbaselines\u002Fsortkey-misalignment-seq-scan.md",565,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fredshift-query-troubleshooter\u002Fevals\u002Fbaselines\u002Fsortkey-misalignment-seq-scan.md",{"path":86,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":87,"sourceHtmlUrl":88},"evals\u002Fbaselines\u002Ftable-lock-copy-blocking-select.md",551,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fredshift-query-troubleshooter\u002Fevals\u002Fbaselines\u002Ftable-lock-copy-blocking-select.md",{"path":90,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":91,"sourceHtmlUrl":92},"evals\u002Fbaselines\u002Fwlm-queue-timeout.md",547,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fredshift-query-troubleshooter\u002Fevals\u002Fbaselines\u002Fwlm-queue-timeout.md",{"path":94,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":95,"sourceHtmlUrl":96},"evals\u002Feval_config.yaml",1992,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fredshift-query-troubleshooter\u002Fevals\u002Feval_config.yaml",{"path":98,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":99,"sourceHtmlUrl":100},"evals\u002Fevals.json",4791,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fredshift-query-troubleshooter\u002Fevals\u002Fevals.json",{"path":102,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":103,"sourceHtmlUrl":104},"evals\u002Fprompts\u002Fcopy-data-format-delimiter.md",1271,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fredshift-query-troubleshooter\u002Fevals\u002Fprompts\u002Fcopy-data-format-delimiter.md",{"path":106,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":107,"sourceHtmlUrl":108},"evals\u002Fprompts\u002Fdistkey-skew-ds-dist-all-inner.md",1399,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fredshift-query-troubleshooter\u002Fevals\u002Fprompts\u002Fdistkey-skew-ds-dist-all-inner.md",{"path":110,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":111,"sourceHtmlUrl":112},"evals\u002Fprompts\u002Fsortkey-misalignment-seq-scan.md",1419,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fredshift-query-troubleshooter\u002Fevals\u002Fprompts\u002Fsortkey-misalignment-seq-scan.md",{"path":114,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":115,"sourceHtmlUrl":116},"evals\u002Fprompts\u002Ftable-lock-copy-blocking-select.md",1304,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fredshift-query-troubleshooter\u002Fevals\u002Fprompts\u002Ftable-lock-copy-blocking-select.md",{"path":118,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":119,"sourceHtmlUrl":120},"evals\u002Fprompts\u002Fwlm-queue-timeout.md",1189,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fredshift-query-troubleshooter\u002Fevals\u002Fprompts\u002Fwlm-queue-timeout.md",{"path":122,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":123,"sourceHtmlUrl":124},"examples\u002FREADME.md",6677,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fredshift-query-troubleshooter\u002Fexamples\u002FREADME.md",{"path":126,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":127,"sourceHtmlUrl":128},"references\u002Fadvanced-patterns.md",9422,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fredshift-query-troubleshooter\u002Freferences\u002Fadvanced-patterns.md",{"path":130,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":131,"sourceHtmlUrl":132},"references\u002Fdiagnostic-sql-reference.md",15621,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fredshift-query-troubleshooter\u002Freferences\u002Fdiagnostic-sql-reference.md",{"path":134,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":135,"sourceHtmlUrl":136},"references\u002Ferror-handling.md",7495,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fredshift-query-troubleshooter\u002Freferences\u002Ferror-handling.md",{"path":138,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":139,"sourceHtmlUrl":140},"references\u002Fexplain-scan-reference.md",10525,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fredshift-query-troubleshooter\u002Freferences\u002Fexplain-scan-reference.md",{"path":142,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":143,"sourceHtmlUrl":144},"references\u002Fworked-examples.md",4070,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fredshift-query-troubleshooter\u002Freferences\u002Fworked-examples.md",{"path":146,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":147,"sourceHtmlUrl":148},"skill.usf.yaml",4543,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fredshift-query-troubleshooter\u002Fskill.usf.yaml",[150,157,164,171,178,185],{"skillNo":151,"name":152,"nameZh":6,"description":153,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":154,"categories":155,"keywords":156,"publishedAt":19},"01M7ADVD60X4PCAPKSE58P9NDC","xray-tracing-deployer","Deploys AWS X-Ray distributed tracing with production-grade configuration: X-Ray daemon deployment (EC2 systemd, ECS sidecar, EKS DaemonSet, Lambda built-in), SDK instrumentation (Java, Python, Node.js, Go, .NET) with annotations and metadata, sampling rules (default reservoir + rate vs custom rules with URL \u002F method \u002F service-name predicates), service map generation, trace query and retrieval, groups and insights, CloudWatch ServiceLens integration, IAM permissions (PutTraceSegments, GetSamplingRules), and latest features (Lambda Powertools tracing, OpenTelemetry \u002F ADOT Collector support, W3C trace context). Emits a READY_TO_DEPLOY checklist with every configuration item verified. Use when enabling X-Ray on a new application, adding tracing to ECS \u002F EKS \u002F Lambda, validating a sampling configuration, or generating daemon deployment CLI and IaC templates. Triggers: X-Ray, distributed tracing, X-Ray daemon, sampling rules, service map, X-Ray SDK, OpenTelemetry, ADOT, Lambda Powertools, CloudWatch ServiceLens.","https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fxray-tracing-deployer\u002FSKILL.md",[],[],{"skillNo":158,"name":159,"nameZh":6,"description":160,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":161,"categories":162,"keywords":163,"publishedAt":19},"01M7ADTVJ7DCBM9CB1FY51GH7J","wellarchitected-workload-auditor","Audits AWS Well-Architected Tool workloads for review staleness, per-pillar high-risk issue counts, milestone tracking gaps, and remediation plan completeness. Emits a deterministic verdict (STALE_REVIEW | HIGH_RISK | CONFIG_GAP | OK) per workload with per-pillar risk breakdown, milestone trend analysis, and specific remediation. Use when reviewing Well-Architected workloads, checking WA review freshness, auditing high-risk issues per pillar, validating milestone coverage, or tracking remediation plans.","https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fwellarchitected-workload-auditor\u002FSKILL.md",[],[],{"skillNo":165,"name":166,"nameZh":6,"description":167,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":168,"categories":169,"keywords":170,"publishedAt":19},"01M7ADT59G6FTTNZYHT2QRPNNP","wellarchitected-review-operator","Operates AWS Well-Architected Tool reviews end-to-end — creates workloads, runs pillar reviews (operational excellence, security, reliability, performance, cost optimization, sustainability, Prosperity), answers questions with risk-tier rationale, generates reports and improvement plans, creates milestones, and integrates with Trusted Advisor and Well-Architected Labs. Runs deterministic pre-checks (workload existence, lens availability, pillar coverage), emits the exact update-answer \u002F get-consolidated-report CLI behind a CONFIRM gate, and verifies risk-tier transitions. Emits READY | BLOCKED | COMPLETED. Use when creating a workload, answering pillar questions, generating an improvement plan, creating a milestone, or integrating with Trusted Advisor. Triggers: well-architected tool, well architected review, workload review, pillar, operational excellence, security, reliability, performance, cost optimization, sustainability, prosperity, improvement plan, milestone, trusted advisor.","https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fwellarchitected-review-operator\u002FSKILL.md",[],[],{"skillNo":172,"name":173,"nameZh":6,"description":174,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":175,"categories":176,"keywords":177,"publishedAt":19},"01M7ADSH5JA9QHNPPHQCD7EVA7","wafv2-web-acl-deployer","Provisions AWS WAFv2 Web ACLs with correct production defaults: scope selection (CLOUDFRONT vs REGIONAL), managed rule groups (AWSManagedRulesCommonRuleSet, SQLiRuleSet, LinuxRuleSet, WindowsRuleSet, IPReputationList, BotControlRuleSet, AmazonIpReputationList, ATP), custom rules (byte match, IP set, regex pattern, geo match, size constraint, rate-based), rule priority ordering, logging destinations (Kinesis Firehose, CloudWatch Logs, S3), resource association (ALB, API Gateway, CloudFront), rate-based rules with aggregate keys (IP, forwarded IP), Challenge and CAPTCHA actions, and account takeover prevention. Emits a READY_TO_DEPLOY checklist. Use when creating a Web ACL, attaching managed rules, configuring rate limiting, enabling WAF logging, associating a Web ACL with an ALB\u002FAPI Gateway\u002FCloudFront, or configuring CAPTCHA\u002FChallenge actions. Triggers: create WAF Web ACL, WAFv2, managed rule groups, WAF rate limiting, WAF logging, WAF CAPTCHA, WAF Challenge action, bot control, ATP managed rules.","https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fwafv2-web-acl-deployer\u002FSKILL.md",[],[],{"skillNo":179,"name":180,"nameZh":6,"description":181,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":182,"categories":183,"keywords":184,"publishedAt":19},"01M7ADRYFAT8R73FBNCHRC573X","wafv2-web-acl-auditor","Audits AWS WAFv2 Web ACL configurations to determine whether the ACL provides effective protection: default-action posture (Allow vs Block), managed-rule-group coverage gaps, rule effectiveness (BLOCK vs COUNT, shadow\u002Fbypass rules, stale exclusions), rate-based rule correctness, logging and visibility configuration, and text-transformation bypass vectors. Emits a deterministic verdict per Web ACL. Use when reviewing a WAFv2 Web ACL for security posture, checking managed-rule coverage, validating rate-limit configuration, auditing WAF logging, or hardening a WAF before production deployment. Triggers: WAF, WAFv2, Web ACL, managed rule group, AWSManagedRules, rate-based rule, CAPTCHA, Challenge, OverrideAction, Count mode, forwarded IP, Bot Control, ATP, text transformation, WAF logging, WAF visibility, OWASP, SQLi, XSS, RFI.","https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fwafv2-web-acl-auditor\u002FSKILL.md",[],[],{"skillNo":186,"name":187,"nameZh":6,"description":188,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":189,"categories":190,"keywords":191,"publishedAt":19},"01M7ADR8W7G72JX4KFGN03QK8Q","waf-rule-deployer","Provisions AWS WAFv2 rule sets with production defaults: Web ACL creation (CloudFront scope in us-east-1 vs Regional scope), rule groups (managed vs custom) with capacity planning in WCU (Web ACL Capacity Units, 1500 default per ACL), managed rule groups (AWSManagedRulesCommonRuleSet, AWSManagedRulesSQLiRuleSet, AWSManagedRulesAmazonIpReputationList, AWSManagedRulesLinuxRuleSet, AWSManagedRulesWindowsRuleSet, AWSManagedRulesUnixRuleSet), custom rules (byte-match, regex pattern set, geo-match, rate-based), IP set and regex pattern set resources, rule priority ordering (lowest number evaluated first), action types (allow, block, count, CAPTCHA, Challenge), bot control managed rule group, account takeover. Triggers: create WAF rule, WAF managed rule group, WAF custom rule, WAF byte match, WAF geo match, WAF rate based rule, WAF IP set, WAF regex pattern set, WAF WCU budget, WAF CloudFront ACL, WAF logging Kinesis Firehose, WAF bot control, WAF ATP, WAF label matching, WAF Challenge action, WAF CAPTCHA.","https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fwaf-rule-deployer\u002FSKILL.md",[],[]]