[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7A3J6KXCFJH5MFYZG2SFCQ4":3,"skill-same:01M7A3J6KXCFJH5MFYZG2SFCQ4":144},{"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":44,"commitSha":45,"skillDirectory":46,"forksCount":47,"repositoryHtmlUrl":48,"repositoryHomepageUrl":6,"ownerHtmlUrl":49,"ownerBlogUrl":6,"ownerDescription":50,"updatedAt":51,"install":52,"resources":65},"01M7A3J6KXCFJH5MFYZG2SFCQ4","athena-query-optimizer",null,"Optimizes Amazon Athena query performance and cost via a layered analysis framework covering partitioning (partition projection, dynamic partition pruning), file format selection (Parquet vs CSV vs JSON — Parquet is 10-100x faster via columnar pruning), compression (Snappy vs GZIP vs ZSTD), bucketing for JOIN optimization, workgroup settings (data scanned limits, query timeout), CTAS (CREATE TABLE AS SELECT for materialization), query rewriting (avoid SELECT *, enforce partition filters, use APPROXIMATE functions), and cost modeling ($5\u002FTB scanned). Supports Athena query result reuse, Athena federated queries, and Spark notebook integration. Emits a deterministic verdict (OPTIMIZED | OPPORTUNITY_FOUND | ALREADY_OPTIMAL) with estimated cost and performance impact. Use for Athena cost reduction, slow query tuning, partition projection setup, file format migration, or workgroup spend limits.","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\u002Fathena-query-optimizer\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: athena-query-optimizer\ndescription: Optimizes Amazon Athena query performance and cost via a layered analysis framework covering partitioning (partition projection, dynamic partition pruning), file format selection (Parquet vs CSV vs JSON — Parquet is 10-100x faster via columnar pruning), compression (Snappy vs GZIP vs ZSTD), bucketing for JOIN optimization, workgroup settings (data scanned limits, query timeout), CTAS (CREATE TABLE AS SELECT for materialization), query rewriting (avoid SELECT *, enforce partition filters, use APPROXIMATE functions), and cost modeling ($5\u002FTB scanned). Supports Athena query result reuse, Athena federated queries, and Spark notebook integration. Emits a deterministic verdict (OPTIMIZED | OPPORTUNITY_FOUND | ALREADY_OPTIMAL) with estimated cost and performance impact. Use for Athena cost reduction, slow query tuning, partition projection setup, file format migration, or workgroup spend limits.\nlicense: Apache-2.0\ncompatibility: Agent runtime that reads SKILL.md (Claude Code, Cursor, Windsurf, Codex, Gemini). Offline recommendation classification works from pasted DDL, EXPLAIN output, and query history. Live-account optimization uses aws athena get-query-execution, start-query-execution, batch-get-query-execution, get-work-group, aws ce get-cost-and-usage for Athena spend, aws glue get-table, get-partitions for table metadata, and aws s3 ls for data lake layout inspection (AWS CLI v2, SSO or key-based credentials).\nmetadata:\n  domain: aws-cloudops\n  complexity: high\n  requires_llm: 'true'\n  phase: '3'\n  supports_pipeline: 'true'\n  entry_point: 'false'\n  family: Analytics\n  task_type: optimize\n  skill_class: capability\n  lifecycle_status: active\n  verdict_shape: OPTIMIZED | OPPORTUNITY_FOUND | ALREADY_OPTIMAL\n  when_to_use: 'Optimizing Athena query performance and cost: reducing data scanned via partitioning and columnar formats, setting up partition projection, evaluating CTAS for materialization, tuning workgroup settings (data scanned limits, query timeout), rewriting queries (avoid SELECT *, add partition filters, use APPROXIMATE functions), or planning a file format migration from CSV\u002FJSON to Parquet.'\n  when_not_to_use: Troubleshooting Athena query failures (use a troubleshoot skill), auditing Athena workgroup security (use the audit-athena-workgroup skill), building a data lake from scratch (use a deploy skill), or Athena Glue crawler troubleshooting (use a Glue troubleshoot skill). This skill focuses on performance and cost optimization.\n  activation_triggers: optimize Athena query, Athena query slow, Athena cost reduction, Athena partition projection, Athena file format Parquet, Athena CTAS optimization, Athena data scanned limit, Athena workgroup settings, Athena SELECT * optimization, Athena $5\u002FTB scanned, Athena result reuse, Athena federated query, reduce Athena spend, Athena query timeout, Athena bucketing\n  invocation_schema: 'Input: either (a) an Athena query or workload description with table DDL and query patterns, OR (b) live-account context with workgroup, database, table, and query history. Output: a deterministic TARGET \u002F VERDICT \u002F REASON \u002F RECOMMENDATION \u002F ESTIMATED_SAVINGS \u002F MIGRATION_STEPS block where VERDICT is one of {OPTIMIZED, OPPORTUNITY_FOUND, ALREADY_OPTIMAL} and RECOMMENDATION includes file format, partitioning strategy, query rewrite, workgroup config, and materialization (CTAS) guidance.'\n  version: 0.1.0\n  author: Jacky Chan — AWS Community Builder\n  keywords: Athena, query optimization, partitioning, partition projection, Parquet, columnar format, Snappy, compression, bucketing, workgroup, data scanned, CTAS, materialization, SELECT *, APPROXIMATE, $5\u002FTB, result reuse, federated queries, Spark notebook\n  tags: aws, athena, analytics, optimize, query-performance, cost-optimization, partitioning, parquet\n---\n\n# Athena Query Optimizer\n\n## Quick start\n\n- **Data scanned is the cost driver.** Athena charges $5\u002FTB scanned. The\n  fastest path to savings is reducing data scanned: partition pruning (filter\n  by partition column), columnar pruning (Parquet — only read needed columns),\n  and CTAS materialization (pre-compute aggregations).\n- **Decision framework (apply in order):**\n  - File format: CSV\u002FJSON → Parquet (10-100x faster, 50-90% less scanned).\n  - Partitioning: unpartitioned → partition by date\u002Ftime column. Partitioned\n    → add partition projection if > 100K partitions.\n  - Query rewriting: SELECT * → SELECT specific columns; missing WHERE on\n    partition column → add filter; COUNT(DISTINCT) → APPROX_COUNT_DISTINCT.\n  - Workgroup: no data scanned limit → set one. No timeout → set one.\n  - CTAS: repeated full-table scans → materialize the aggregation.\n  - Advanced: bucketing for JOIN-heavy workloads, result reuse for repeated\n    queries.\n- **Parquet + Snappy is the default recommendation.** Columnar storage +\n  fast decompression = 10-100x faster scans and 50-90% less data read. Every\n  CSV\u002FJSON table in Athena is an optimization opportunity.\n- **$5\u002FTB makes small wins matter.** A query scanning 500 GB costs $2.50. If\n  it runs 100 times\u002Fday, that is $250\u002Fday = $7,500\u002Fmonth. Partition pruning\n  to scan 10 GB drops it to $150\u002Fmonth.\n\n## STRICT output contract\n\nEvery optimization response MUST emit this block per target (table, query, or\nworkgroup). No prose before or after the block.\n\n```text\nTARGET: \u003Cdatabase\u002Ftable | query-id | workgroup>\nVERDICT: OPTIMIZED | OPPORTUNITY_FOUND | ALREADY_OPTIMAL\nREASON: \u003C1-2 sentences naming the recommendation and the supporting data>\nRECOMMENDATION:\n  Current: \u003Cfile format | partitioning | query pattern | workgroup config>\n  Proposed: \u003Cfile format | partitioning | query pattern | workgroup config>\n  File format: \u003CCSV | JSON | Parquet | ORC>\n  Compression: \u003Cnone | GZIP | Snappy | ZSTD>\n  Partitioning: \u003Cnone | date column | partition projection>\n  Query rewrite: \u003Cavoid SELECT * | add partition filter | APPROXIMATE | none>\n  Workgroup: \u003Cdata scanned limit | query timeout | result reuse>\n  CTAS: \u003Cmaterialization target | none>\n  Confidence: \u003CHIGH\u002FMEDIUM\u002FLOW> — \u003Cone-line rationale>\nESTIMATED_SAVINGS:\n  Cost (monthly): $\u003Camount>  (\u003Ccurrent scan> → \u003Cproposed scan>)\n  Performance: \u003Ccurrent runtime> → \u003Cproposed runtime>\n  Data scanned per query: \u003Ccurrent> → \u003Cproposed>\n  Annual total: $\u003Camount>\n  Assumptions: \u003C$5\u002FTB, query frequency, etc.>\nMIGRATION_STEPS:\n  1. \u003Cspecific action with DDL or CLI command>\n  2. \u003Cverification step>\nCONFIRM: Before executing any CTAS or workgroup config change, emit and await\n  operator approval.\n```\n\nDo NOT omit any field. If a field is not applicable, write `N\u002FA` with a\none-line reason.\n\n## Quick navigation\n\n| Section | What it covers | When to read |\n|---|---|---|\n| **Quick start** | Decision framework order, Parquet rule of thumb | First read |\n| **STRICT output contract** | Mandatory output block format | Before emitting |\n| **Mindset** | Data-scanned-first philosophy, Parquet dominance | Understanding |\n| **Quick reference** | Verdict thresholds | Classifying findings |\n| **Pre-flight** | Data gate — query history, DDL, data lake layout | Before decisions |\n| **Process** | Ordered optimization steps (1-10) | Choosing recommendations |\n| **Output format** | Worked example (OPPORTUNITY_FOUND) | Formatting |\n| **Expert heuristic** | Non-obvious Athena behaviours table | Complex decisions |\n| **NEVER** | Top 5 anti-patterns | Before remediation |\n| `references\u002F` | CLI commands, worked examples, full heuristics | Deep reference |\n\n## Mindset\n\nAthena optimization is a layered decision. Four behaviours separate a senior\nanalytics engineer from a generalist:\n\n- **Data scanned is the only cost lever.** Athena charges by bytes read from\n  S3, not by compute time. Reducing data scanned is the ONLY way to reduce\n  cost. Everything else (compression, caching, result reuse) reduces bytes\n  read as a side effect.\n- **File format is the highest-leverage single change.** Switching from CSV\n  to Parquet reduces data scanned by 50-90% (columnar pruning + compression)\n  and improves query speed by 10-100x. This is always Step 1.\n- **Partitioning amplifies file format gains.** A Parquet table partitioned\n  by date lets a query scanning one day of a year-long dataset read 1\u002F365th\n  of the data. Unpartitioned, it scans the full table even in Parquet.\n- **Workgroup settings prevent runaway spend.** A data-scanned limit caps\n  the worst-case cost of any single query. Without it, a single `SELECT *`\n  on a petabyte table costs $5,000.\n\n## Quick reference — verdict thresholds\n\n| Observation | Verdict | Recommendation |\n|---|---|---|\n| Table in CSV or JSON format | OPPORTUNITY_FOUND (file format) | Step 2 — CTAS to Parquet + Snappy |\n| Table unpartitioned, queries filter by date\u002Ftime | OPPORTUNITY_FOUND (partitioning) | Step 3 — add partition column + ALTER TABLE |\n| Partitioned table with > 100K partitions, slow metadata ops | OPPORTUNITY_FOUND (partition projection) | Step 4 — enable partition projection |\n| Query uses `SELECT *` | OPPORTUNITY_FOUND (query rewrite) | Step 6 — select only needed columns |\n| Query scans full table without partition filter | OPPORTUNITY_FOUND (query rewrite) | Step 6 — add WHERE on partition column |\n| Repeated full-table aggregation scan | OPPORTUNITY_FOUND (CTAS) | Step 7 — materialize the aggregation |\n| Workgroup has no data scanned limit | OPPORTUNITY_FOUND (workgroup) | Step 8 — set data scanned limit |\n| Parquet + partitioned + partition projection + tight queries | ALREADY_OPTIMAL | None — continue monitoring |\n| Post-remediation: changes applied and verified | OPTIMIZED | None — verification passed |\n\n## Pre-flight: data gate (run before any optimization decision)\n\n**Required data:** table DDL (file format, partition columns, compression),\nquery history (data scanned per query, frequency), and data lake S3 layout.\nKey commands: `aws glue get-table`, `aws glue get-partitions`,\n`aws athena batch-get-query-execution`, `aws s3 ls`.\n\nFull CLI sequences in `references\u002Fathena-optimization-reference.md`.\n\n### Data-quality short-circuits\n\n| Condition | Effect on optimization |\n|---|---|\n| No query history available | MEDIUM confidence; base estimates on DDL + S3 size |\n| Table not in Glue catalog | NEED_MORE_INFO: register in Glue first |\n| Federated query (non-S3 source) | Different cost model — connector-dependent; not $5\u002FTB |\n| Table has 0 bytes (empty) | Skip — no cost to optimize |\n\n## Process — Optimization logic (apply in order)\n\n### Step 1: Validate input and data sufficiency\n\nDiagnostic CLI (table DDL and properties, query history, batch execution\ndetails — data scanned, runtime, status): [Diagnostic commands](references\u002Fdiagnostic-commands.md).\n\n### Step 2: File format optimization (highest-leverage single change)\n\n| Current format | Target format | Speedup | Data scanned reduction |\n|---|---|---|---|\n| CSV (row-based, no compression) | Parquet + Snappy | 10-100x | 50-90% |\n| JSON (row-based) | Parquet + Snappy | 10-50x | 50-80% |\n| Parquet + uncompressed | Parquet + Snappy | 2-3x | 20-40% |\n| Parquet + GZIP | Parquet + Snappy | 1.5-2x | 5-15% (Snappy faster, similar ratio) |\n| ORC + ZSTD | Keep (already columnar) | — | — |\n\n**Parquet vs CSV anatomy:** CSV is row-based and stores all columns for each\nrow. A query selecting 3 of 50 columns still reads all 50 columns. Parquet is\ncolumnar: a query selecting 3 of 50 columns reads only those 3 columns from\ndisk. This is columnar pruning, and it is the #1 reason Parquet is 10-100x\nfaster.\n\n**CTAS migration to Parquet:**\n\n```sql\n-- Create the Parquet table from the CSV table:\nCREATE TABLE \u003Cdb>.\u003Ctable>_parquet\nWITH (\n  format = 'PARQUET',\n  parquet_compression = 'SNAPPY',\n  external_location = 's3:\u002F\u002F\u003Cbucket>\u002F\u003Cprefix>\u002Fparquet\u002F'\n) AS\nSELECT * FROM \u003Cdb>.\u003Ctable>_csv;\n```\n\n### Step 3: Partitioning optimization\n\nPartitioning splits data into S3 subdirectories by column value. Queries with\na WHERE clause on the partition column read only the matching partitions.\n\n| Partitioning state | Recommendation |\n|---|---|\n| Unpartitioned, queries filter by date\u002Ftime | Add partition by date (e.g., `dt='2026-08-01'`) |\n| Partitioned by high-cardinality column (e.g., user_id) | Switch to bucketing or secondary partition by date |\n| Over-partitioned (> 100K partitions) | Enable partition projection (Step 4) |\n| Partitioned by hour (too many small files) | Consolidate to daily partitions |\n\n**Add partitioning via CTAS:**\n\n```sql\nCREATE TABLE \u003Cdb>.\u003Ctable>_partitioned\nWITH (\n  format = 'PARQUET',\n  parquet_compression = 'SNAPPY',\n  partitioned_by = ARRAY['dt'],\n  external_location = 's3:\u002F\u002F\u003Cbucket>\u002F\u003Cprefix>\u002Fpartitioned\u002F'\n) AS\nSELECT col1, col2, ..., date_format(event_time, '%Y-%m-%d') AS dt\nFROM \u003Cdb>.\u003Ctable>_unpartitioned;\n```\n\n**Optimal partition size:** 100 MB - 1 GB per partition file. Too many small\nfiles (\u003C 100 MB) cause S3 request overhead. Too few large files (> 1 GB)\nreduce parallelism.\n\n### Step 4: Partition projection\n\nPartition projection lets Athena calculate partition values mathematically\ninstead of querying Glue for each partition. Essential for tables with\n10K-100K+ partitions.\n\n**When to use:** Glue `get-partitions` is slow (> 5s), partition count >\n100K, or partitions follow a predictable pattern (date ranges, integer\nranges).\n\n```sql\n-- Enable partition projection on an existing table:\nALTER TABLE \u003Cdb>.\u003Ctable> SET TBLPROPERTIES (\n  'projection.enabled' = 'true',\n  'projection.dt.type' = 'date',\n  'projection.dt.range' = '2024-01-01,2026-12-31',\n  'projection.dt.format' = 'yyyy-MM-dd',\n  'projection.dt.interval' = '1',\n  'projection.dt.interval.unit' = 'DAYS',\n  'storage.location.template' = 's3:\u002F\u002F\u003Cbucket>\u002F\u003Cprefix>\u002F${dt}'\n);\n```\n\nPartition projection eliminates the need for `MSCK REPAIR TABLE` or\n`ALTER TABLE ADD PARTITION` — Athena auto-discovers partitions within the\nconfigured range.\n\n### Step 5: Compression optimization\n\n| Compression | Ratio | Speed | Recommendation |\n|---|---|---|---|\n| None (uncompressed) | 1:1 | Fastest read | Never use for Athena |\n| Snappy | ~3:1 | Fastest decompression | **Default for Parquet** |\n| GZIP | ~4:1 | 2-3x slower than Snappy | Use for cold storage; hurts query speed |\n| ZSTD | ~4:1 | Between Snappy and GZIP | Good for large datasets; level 3-9 |\n| LZ4 | ~2.5:1 | Faster than Snappy | Alternative for latency-sensitive |\n\n**Rule of thumb:** Use Snappy for Parquet (best speed\u002Fratio balance). Avoid\nGZIP for Athena queries — the decompression overhead outweighs the better\ncompression ratio for query workloads. ZSTD is a good upgrade from Snappy for\nvery large datasets where the better ratio reduces S3 GET costs.\n\n### Step 6: Query rewriting\n\n| Pattern | Problem | Fix | Impact |\n|---|---|---|---|\n| `SELECT *` | Reads all columns, even unused | `SELECT col1, col2` (only needed) | 50-90% scan reduction |\n| No WHERE on partition column | Full table scan | `WHERE dt >= '2026-07-01'` | Proportional to partition pruning |\n| `COUNT(DISTINCT col)` | Exact count is expensive | `APPROX_COUNT_DISTINCT(col)` | 10-50x faster, \u003C 3% error |\n| `ORDER BY` without `LIMIT` | Sorts entire dataset | Add `LIMIT N` or use window functions | Reduces sort overhead |\n| `LIKE '%pattern%'` | Full scan, no optimization | Use string functions or pre-process | Variable |\n| Repeated subqueries | Recomputes same data | Use CTE (WITH) or materialize via CTAS | Eliminates redundant scans |\n| `JOIN` on unbucketed large tables | Shuffle-heavy | Bucket both tables on join key (Step 9) | Eliminates shuffle |\n| `UNION` (not `UNION ALL`) | Deduplication overhead | Use `UNION ALL` if no dupes expected | Eliminates sort |\n\n```sql\n-- Before (scans all columns + all partitions):\nSELECT * FROM sales WHERE amount > 100;\n\n-- After (only needed columns + partition filter):\nSELECT order_id, customer_id, amount\nFROM sales\nWHERE dt >= '2026-07-01' AND amount > 100;\n```\n\n### Step 7: CTAS materialization\n\nIf a query (or query pattern) runs frequently and scans a large table to\nproduce a small result, materialize it with CTAS.\n\n**When to use CTAS:**\n- Daily\u002Fweekly aggregation queries scanning raw event data.\n- Complex JOINs that produce a denormalized reporting table.\n- Queries that scan > 100 GB to produce \u003C 1 GB of results.\n\n```sql\n-- Materialize a daily aggregation from raw events:\nCREATE TABLE \u003Cdb>.daily_summary\nWITH (\n  format = 'PARQUET',\n  parquet_compression = 'SNAPPY',\n  partitioned_by = ARRAY['dt'],\n  external_location = 's3:\u002F\u002F\u003Cbucket>\u002Fcurated\u002Fdaily_summary\u002F'\n) AS\nSELECT\n  date_trunc('day', event_time) AS day,\n  product_id,\n  COUNT(*) AS event_count,\n  SUM(amount) AS total_amount\nFROM \u003Cdb>.raw_events\nWHERE dt >= '2026-01-01'\nGROUP BY 1, 2;\n```\n\n**Cost trade-off:** The CTAS itself scans data once (costs $X). Subsequent\nqueries on the materialized table scan far less (costs $X\u002FN per query).\nBreak-even depends on query frequency. If the daily summary is queried 10+\ntimes\u002Fday, CTAS pays for itself within a day.\n\n### Step 8: Workgroup settings\n\n| Setting | Purpose | Recommendation |\n|---|---|---|\n| Data scanned limit (bytes) | Caps worst-case cost per query | Set to p99 of healthy queries × 2 |\n| Query timeout (minutes) | Prevents runaway queries | 30 min for interactive; 6 hours for batch |\n| Requester pays | Shifts cost to query requester | Enable for shared workgroups |\n| Result reuse | Caches identical query results | Enable for dashboard workloads |\n| Enforced workgroup config | Prevents users from bypassing limits | Set `EnforceWorkGroupConfiguration: true` |\n\n```bash\n# Update workgroup with data scanned limit:\naws athena update-work-group \\\n  --work-group \u003Cwg> \\\n  --configuration '{\n    \"ResultConfiguration\": {\"OutputLocation\": \"s3:\u002F\u002F\u003Cbucket>\u002Fresults\u002F\"},\n    \"EnforceWorkGroupConfiguration\": true,\n    \"PublishCloudWatchMetricsEnabled\": true,\n    \"BytesScannedCutoffPerQuery\": 10737418240,\n    \"EngineVersion\": {\"SelectedEngineVersion\": \"Athena engine version 3\"}\n  }'\n```\n\n**Data scanned limit of 10 GB** caps any single query at $0.05. Adjust\nbased on your workload's normal query sizes.\n\n### Step 9: Bucketing for JOIN optimization\n\nBucketing pre-splits data into N files by a hash of the bucket column.\nWhen two tables are bucketed on the same join key with the same bucket\ncount, Athena can perform a bucket-map JOIN without shuffling.\n\n```sql\n-- Create bucketed tables for a large JOIN:\nCREATE TABLE \u003Cdb>.orders_bucketed\nWITH (\n  format = 'PARQUET',\n  parquet_compression = 'SNAPPY',\n  bucketed_by = ARRAY['customer_id'],\n  bucket_count = 256,\n  external_location = 's3:\u002F\u002F\u003Cbucket>\u002Fbucketed\u002Forders\u002F'\n) AS SELECT * FROM \u003Cdb>.orders;\n\nCREATE TABLE \u003Cdb>.customers_bucketed\nWITH (\n  format = 'PARQUET',\n  parquet_compression = 'SNAPPY',\n  bucketed_by = ARRAY['customer_id'],\n  bucket_count = 256,\n  external_location = 's3:\u002F\u002F\u003Cbucket>\u002Fbucketed\u002Fcustomers\u002F'\n) AS SELECT * FROM \u003Cdb>.customers;\n```\n\n**When bucketing helps:** Large-table-to-large-table JOINs (both > 10 GB).\nNot helpful for dimension tables \u003C 1 GB (Athena broadcasts small tables\nautomatically).\n\n### Step 10: Impact estimation and final verdict\n\n```\nFile format savings = (csv_bytes_scanned - parquet_bytes_scanned) * $5\u002FTB * query_freq\nPartition pruning savings = (full_table_scan - partition_scan) * $5\u002FTB * query_freq\nCTAS savings = (raw_scan - materialized_scan) * $5\u002FTB * query_freq - ctas_creation_cost\n```\n\nVerdict: any dimension with a concrete recommendation → **OPPORTUNITY_FOUND**.\nAll dimensions pass → **ALREADY_OPTIMAL**. Changes applied and verified →\n**OPTIMIZED**.\n\n## Output format\n\nSee STRICT output contract above. Worked example below. Additional examples\n(CSV to Parquet migration, ALREADY_OPTIMAL, NEED_MORE_INFO) in\n`references\u002Fathena-optimization-reference.md`.\n\n### Worked example — CSV to Parquet + partitioning + workgroup limit\n\n```text\nTARGET: analytics_db.events_raw\nVERDICT: OPPORTUNITY_FOUND\nREASON: Table is unpartitioned CSV (1.2 TB). Top 10 queries scan the full\n  table averaging 320s runtime. Migrating to Parquet + partitioning by date\n  reduces average scan from 1.2 TB to 18 GB (daily queries). Adding a 10 GB\n  data-scanned limit prevents runaway scans.\nRECOMMENDATION:\n  Current: CSV, unpartitioned, no compression, no workgroup limit\n  Proposed: Parquet + Snappy, partitioned by dt, 10 GB workgroup limit\n  File format: CSV → Parquet\n  Compression: none → Snappy\n  Partitioning: none → partitioned_by = ['dt']\n  Query rewrite: SELECT * → SELECT 8 of 42 columns; add WHERE dt filter\n  Workgroup: no limit → 10 GB data scanned per query\n  CTAS: materialize daily_summary aggregation table\n  Confidence: HIGH — DDL confirms CSV\u002Funpartitioned, query history shows\n    daily date-filtered queries scanning 1.2 TB each.\nESTIMATED_SAVINGS:\n  Cost (monthly): $3,280.50 → $49.10\n    (1.2 TB × $5 × 220 queries\u002Fmonth → 18 GB × $5 × 220 queries\u002Fmonth)\n  Performance: 320s avg → 8s avg (40x faster)\n  Data scanned per query: 1.2 TB → 18 GB (98.5% reduction)\n  Annual total: $38,774.40\n  Assumptions: $5\u002FTB, 220 daily-filtered queries\u002Fmonth, 1\u002F30th data per\n    partition after date partitioning + columnar pruning.\nMIGRATION_STEPS:\n  1. Create the Parquet partitioned table via CTAS:\n     CREATE TABLE analytics_db.events_parquet\n     WITH (format='PARQUET', parquet_compression='SNAPPY',\n           partitioned_by=ARRAY['dt'],\n           external_location='s3:\u002F\u002F\u003Cbucket>\u002Fevents\u002Fparquet\u002F')\n     AS SELECT event_id, user_id, event_type, amount, device, country,\n       ip_address, session_id,\n       date_format(event_time, '%Y-%m-%d') AS dt\n     FROM analytics_db.events_raw;\n  2. Verify row count parity:\n     SELECT COUNT(*) FROM analytics_db.events_parquet;\n     SELECT COUNT(*) FROM analytics_db.events_raw;\n  3. Update downstream queries to use the new table + partition filter:\n     SELECT event_type, COUNT(*) FROM analytics_db.events_parquet\n     WHERE dt >= '2026-07-01' GROUP BY event_type;\n  4. Set the workgroup data-scanned limit:\n     aws athena update-work-group --work-group primary \\\n       --configuration '{\"BytesScannedCutoffPerQuery\":10737418240,...}'\n  5. Monitor query performance for 7 days before decommissioning the CSV table.\nCONFIRM: Before running the CTAS (scans 1.2 TB, cost ~$6.00), emit and await:\n  \"CONFIRM: About to run CTAS migration on analytics_db.events_raw (1.2 TB,\n   estimated cost $6.00). Proceed? (yes\u002Fno)\"\n```\n\n## Verdict semantics\n\n| Verdict | When to emit |\n|---|---|\n| OPPORTUNITY_FOUND | At least one dimension has a concrete, savings-bearing recommendation. |\n| OPTIMIZED | Changes applied and verified this session; queries confirm improvement. |\n| ALREADY_OPTIMAL | Parquet + partitioned + tight queries + workgroup limits in place. |\n\n## Expert heuristic — consolidated\n\nFull heuristic table (cost lever is bytes scanned, columnar pruning, partition pruning, partition projection, Snappy vs GZIP, APPROX_COUNT_DISTINCT, CTAS break-even, workgroup limits, engine v3 dynamic partition pruning, result reuse, federated pricing, small files): [Advanced patterns](references\u002Fadvanced-patterns.md).\n\n## NEVER (top 5)\n\n- **NEVER** recommend changing query patterns without first checking the file\n  format. A `SELECT *` on Parquet is still better than `SELECT *` on CSV, but\n  `SELECT col1, col2` on CSV is still expensive. Fix file format first.\n\n- **NEVER** recommend partitioning without estimating partition size. Too\n  many small partitions (\u003C 100 MB each) cause S3 503 errors and metadata\n  bloat. Consolidate to daily or monthly partitions if hourly files are small.\n\n- **NEVER** recommend GZIP compression for Athena Parquet tables. GZIP's\n  decompression overhead negates the compression advantage for query\n  workloads. Use Snappy (default) or ZSTD.\n\n- **NEVER** set a workgroup data-scanned limit without first measuring normal\n  query sizes. Setting it too low blocks legitimate queries. Measure p99\n  first, then set limit at p99 × 2.\n\n- **NEVER** recommend CTAS materialization without checking query frequency.\n  A CTAS that costs $5 to create but is queried once\u002Fmonth does not break\n  even. Materialize only if query frequency justifies the one-time cost.\n\n## Pre-flight safety checks (run before any remediation)\n\n- **MANDATORY CONFIRMATION GATE** before any CTAS (it scans data and costs $).\n- **Verify row count parity** after CTAS migration before decommissioning\n  the source table.\n- **Verify partition count** after adding partition projection — if the\n  projection range is wrong, Athena may miss partitions.\n- **Batch limit:** max 5 table migrations per batch, single CONFIRM per batch.\n- **Capture pre-state:** record current DDL and query history before changes.\n\n## Recent AWS features (2024-2026)\n\nRecent AWS features (result reuse, federated queries, Spark notebooks, engine v3, Iceberg, parameterized queries): [Advanced patterns](references\u002Fadvanced-patterns.md).\n\n## References (load on demand)\n\n- [Advanced patterns](references\u002Fadvanced-patterns.md) — consolidated expert-heuristic table (non-obvious Athena behaviours) and recent AWS features (result reuse, federated queries, Spark notebooks, engine v3, Iceberg, parameterized queries)\n- [Diagnostic commands](references\u002Fdiagnostic-commands.md) — Step 1 data-gathering CLI (Glue DDL, query history, batch-get execution statistics)\n- `references\u002Fathena-optimization-reference.md` — pre-flight CLI sequences, CTAS templates, partition projection configs, workgroup commands, cost formulas, additional worked examples, full NEVER list\n- `references\u002Ffailure-decision-tree.md` — per-step worked examples and the cross-category decision flowchart\n\n## Domain\n\nAWS CloudOps \u002F Amazon Athena Analytics Query Performance & Cost Optimization.\n\n## AWS documentation\n\n- **Amazon Athena User Guide** — https:\u002F\u002Fdocs.aws.amazon.com\u002Fathena\u002Flatest\u002Fug\u002Fwhat-is.html\n- **Athena performance tuning** — https:\u002F\u002Fdocs.aws.amazon.com\u002Fathena\u002Flatest\u002Fug\u002Fperformance-tuning.html\n- **Athena pricing** — https:\u002F\u002Faws.amazon.com\u002Fathena\u002Fpricing\u002F\n- **Athena CTAS** — https:\u002F\u002Fdocs.aws.amazon.com\u002Fathena\u002Flatest\u002Fug\u002Fctas.html\n- **Partition projection** — https:\u002F\u002Fdocs.aws.amazon.com\u002Fathena\u002Flatest\u002Fug\u002Fpartition-projection.html\n- **Athena query result reuse** — https:\u002F\u002Fdocs.aws.amazon.com\u002Fathena\u002Flatest\u002Fug\u002Fquery-result-reuse.html\n- **Athena federated queries** — https:\u002F\u002Fdocs.aws.amazon.com\u002Fathena\u002Flatest\u002Fug\u002Fconnect-to-a-data-source.html\n- **Athena Spark** — https:\u002F\u002Fdocs.aws.amazon.com\u002Fathena\u002Flatest\u002Fug\u002Fnotebooks-spark.html\n- **Apache Iceberg on Athena** — https:\u002F\u002Fdocs.aws.amazon.com\u002Fathena\u002Flatest\u002Fug\u002Fquerying-iceberg.html\n- **AWS Well-Architected Framework — Performance Efficiency** — https:\u002F\u002Fdocs.aws.amazon.com\u002Fwellarchitected\u002Flatest\u002Fperformance-efficiency-pillar\u002Fwelcome.html\n","# Athena Query Optimizer\n\n## Quick start\n\n- **Data scanned is the cost driver.** Athena charges $5\u002FTB scanned. The\n  fastest path to savings is reducing data scanned: partition pruning (filter\n  by partition column), columnar pruning (Parquet — only read needed columns),\n  and CTAS materialization (pre-compute aggregations).\n- **Decision framework (apply in order):**\n  - File format: CSV\u002FJSON → Parquet (10-100x faster, 50-90% less scanned).\n  - Partitioning: unpartitioned → partition by date\u002Ftime column. Partitioned\n    → add partition projection if > 100K partitions.\n  - Query rewriting: SELECT * → SELECT specific columns; missing WHERE on\n    partition column → add filter; COUNT(DISTINCT) → APPROX_COUNT_DISTINCT.\n  - Workgroup: no data scanned limit → set one. No timeout → set one.\n  - CTAS: repeated full-table scans → materialize the aggregation.\n  - Advanced: bucketing for JOIN-heavy workloads, result reuse for repeated\n    queries.\n- **Parquet + Snappy is the default recommendation.** Columnar storage +\n  fast decompression = 10-100x faster scans and 50-90% less data read. Every\n  CSV\u002FJSON table in Athena is an optimization opportunity.\n- **$5\u002FTB makes small wins matter.** A query scanning 500 GB costs $2.50. If\n  it runs 100 times\u002Fday, that is $250\u002Fday = $7,500\u002Fmonth. Partition pruning\n  to scan 10 GB drops it to $150\u002Fmonth.\n\n## STRICT output contract\n\nEvery optimization response MUST emit this block per target (table, query, or\nworkgroup). No prose before or after the block.\n\n```text\nTARGET: \u003Cdatabase\u002Ftable | query-id | workgroup>\nVERDICT: OPTIMIZED | OPPORTUNITY_FOUND | ALREADY_OPTIMAL\nREASON: \u003C1-2 sentences naming the recommendation and the supporting data>\nRECOMMENDATION:\n  Current: \u003Cfile format | partitioning | query pattern | workgroup config>\n  Proposed: \u003Cfile format | partitioning | query pattern | workgroup config>\n  File format: \u003CCSV | JSON | Parquet | ORC>\n  Compression: \u003Cnone | GZIP | Snappy | ZSTD>\n  Partitioning: \u003Cnone | date column | partition projection>\n  Query rewrite: \u003Cavoid SELECT * | add partition filter | APPROXIMATE | none>\n  Workgroup: \u003Cdata scanned limit | query timeout | result reuse>\n  CTAS: \u003Cmaterialization target | none>\n  Confidence: \u003CHIGH\u002FMEDIUM\u002FLOW> — \u003Cone-line rationale>\nESTIMATED_SAVINGS:\n  Cost (monthly): $\u003Camount>  (\u003Ccurrent scan> → \u003Cproposed scan>)\n  Performance: \u003Ccurrent runtime> → \u003Cproposed runtime>\n  Data scanned per query: \u003Ccurrent> → \u003Cproposed>\n  Annual total: $\u003Camount>\n  Assumptions: \u003C$5\u002FTB, query frequency, etc.>\nMIGRATION_STEPS:\n  1. \u003Cspecific action with DDL or CLI command>\n  2. \u003Cverification step>\nCONFIRM: Before executing any CTAS or workgroup config change, emit and await\n  operator approval.\n```\n\nDo NOT omit any field. If a field is not applicable, write `N\u002FA` with a\none-line reason.\n\n## Quick navigation\n\n| Section | What it covers | When to read |\n|---|---|---|\n| **Quick start** | Decision framework order, Parquet rule of thumb | First read |\n| **STRICT output contract** | Mandatory output block format | Before emitting |\n| **Mindset** | Data-scanned-first philosophy, Parquet dominance | Understanding |\n| **Quick reference** | Verdict thresholds | Classifying findings |\n| **Pre-flight** | Data gate — query history, DDL, data lake layout | Before decisions |\n| **Process** | Ordered optimization steps (1-10) | Choosing recommendations |\n| **Output format** | Worked example (OPPORTUNITY_FOUND) | Formatting |\n| **Expert heuristic** | Non-obvious Athena behaviours table | Complex decisions |\n| **NEVER** | Top 5 anti-patterns | Before remediation |\n| `references\u002F` | CLI commands, worked examples, full heuristics | Deep reference |\n\n## Mindset\n\nAthena optimization is a layered decision. Four behaviours separate a senior\nanalytics engineer from a generalist:\n\n- **Data scanned is the only cost lever.** Athena charges by bytes read from\n  S3, not by compute time. Reducing data scanned is the ONLY way to reduce\n  cost. Everything else (compression, caching, result reuse) reduces bytes\n  read as a side effect.\n- **File format is the highest-leverage single change.** Switching from CSV\n  to Parquet reduces data scanned by 50-90% (columnar pruning + compression)\n  and improves query speed by 10-100x. This is always Step 1.\n- **Partitioning amplifies file format gains.** A Parquet table partitioned\n  by date lets a query scanning one day of a year-long dataset read 1\u002F365th\n  of the data. Unpartitioned, it scans the full table even in Parquet.\n- **Workgroup settings prevent runaway spend.** A data-scanned limit caps\n  the worst-case cost of any single query. Without it, a single `SELECT *`\n  on a petabyte table costs $5,000.\n\n## Quick reference — verdict thresholds\n\n| Observation | Verdict | Recommendation |\n|---|---|---|\n| Table in CSV or JSON format | OPPORTUNITY_FOUND (file format) | Step 2 — CTAS to Parquet + Snappy |\n| Table unpartitioned, queries filter by date\u002Ftime | OPPORTUNITY_FOUND (partitioning) | Step 3 — add partition column + ALTER TABLE |\n| Partitioned table with > 100K partitions, slow metadata ops | OPPORTUNITY_FOUND (partition projection) | Step 4 — enable partition projection |\n| Query uses `SELECT *` | OPPORTUNITY_FOUND (query rewrite) | Step 6 — select only needed columns |\n| Query scans full table without partition filter | OPPORTUNITY_FOUND (query rewrite) | Step 6 — add WHERE on partition column |\n| Repeated full-table aggregation scan | OPPORTUNITY_FOUND (CTAS) | Step 7 — materialize the aggregation |\n| Workgroup has no data scanned limit | OPPORTUNITY_FOUND (workgroup) | Step 8 — set data scanned limit |\n| Parquet + partitioned + partition projection + tight queries | ALREADY_OPTIMAL | None — continue monitoring |\n| Post-remediation: changes applied and verified | OPTIMIZED | None — verification passed |\n\n## Pre-flight: data gate (run before any optimization decision)\n\n**Required data:** table DDL (file format, partition columns, compression),\nquery history (data scanned per query, frequency), and data lake S3 layout.\nKey commands: `aws glue get-table`, `aws glue get-partitions`,\n`aws athena batch-get-query-execution`, `aws s3 ls`.\n\nFull CLI sequences in `references\u002Fathena-optimization-reference.md`.\n\n### Data-quality short-circuits\n\n| Condition | Effect on optimization |\n|---|---|\n| No query history available | MEDIUM confidence; base estimates on DDL + S3 size |\n| Table not in Glue catalog | NEED_MORE_INFO: register in Glue first |\n| Federated query (non-S3 source) | Different cost model — connector-dependent; not $5\u002FTB |\n| Table has 0 bytes (empty) | Skip — no cost to optimize |\n\n## Process — Optimization logic (apply in order)\n\n### Step 1: Validate input and data sufficiency\n\nDiagnostic CLI (table DDL and properties, query history, batch execution\ndetails — data scanned, runtime, status): [Diagnostic commands](references\u002Fdiagnostic-commands.md).\n\n### Step 2: File format optimization (highest-leverage single change)\n\n| Current format | Target format | Speedup | Data scanned reduction |\n|---|---|---|---|\n| CSV (row-based, no compression) | Parquet + Snappy | 10-100x | 50-90% |\n| JSON (row-based) | Parquet + Snappy | 10-50x | 50-80% |\n| Parquet + uncompressed | Parquet + Snappy | 2-3x | 20-40% |\n| Parquet + GZIP | Parquet + Snappy | 1.5-2x | 5-15% (Snappy faster, similar ratio) |\n| ORC + ZSTD | Keep (already columnar) | — | — |\n\n**Parquet vs CSV anatomy:** CSV is row-based and stores all columns for each\nrow. A query selecting 3 of 50 columns still reads all 50 columns. Parquet is\ncolumnar: a query selecting 3 of 50 columns reads only those 3 columns from\ndisk. This is columnar pruning, and it is the #1 reason Parquet is 10-100x\nfaster.\n\n**CTAS migration to Parquet:**\n\n```sql\n-- Create the Parquet table from the CSV table:\nCREATE TABLE \u003Cdb>.\u003Ctable>_parquet\nWITH (\n  format = 'PARQUET',\n  parquet_compression = 'SNAPPY',\n  external_location = 's3:\u002F\u002F\u003Cbucket>\u002F\u003Cprefix>\u002Fparquet\u002F'\n) AS\nSELECT * FROM \u003Cdb>.\u003Ctable>_csv;\n```\n\n### Step 3: Partitioning optimization\n\nPartitioning splits data into S3 subdirectories by column value. Queries with\na WHERE clause on the partition column read only the matching partitions.\n\n| Partitioning state | Recommendation |\n|---|---|\n| Unpartitioned, queries filter by date\u002Ftime | Add partition by date (e.g., `dt='2026-08-01'`) |\n| Partitioned by high-cardinality column (e.g., user_id) | Switch to bucketing or secondary partition by date |\n| Over-partitioned (> 100K partitions) | Enable partition projection (Step 4) |\n| Partitioned by hour (too many small files) | Consolidate to daily partitions |\n\n**Add partitioning via CTAS:**\n\n```sql\nCREATE TABLE \u003Cdb>.\u003Ctable>_partitioned\nWITH (\n  format = 'PARQUET',\n  parquet_compression = 'SNAPPY',\n  partitioned_by = ARRAY['dt'],\n  external_location = 's3:\u002F\u002F\u003Cbucket>\u002F\u003Cprefix>\u002Fpartitioned\u002F'\n) AS\nSELECT col1, col2, ..., date_format(event_time, '%Y-%m-%d') AS dt\nFROM \u003Cdb>.\u003Ctable>_unpartitioned;\n```\n\n**Optimal partition size:** 100 MB - 1 GB per partition file. Too many small\nfiles (\u003C 100 MB) cause S3 request overhead. Too few large files (> 1 GB)\nreduce parallelism.\n\n### Step 4: Partition projection\n\nPartition projection lets Athena calculate partition values mathematically\ninstead of querying Glue for each partition. Essential for tables with\n10K-100K+ partitions.\n\n**When to use:** Glue `get-partitions` is slow (> 5s), partition count >\n100K, or partitions follow a predictable pattern (date ranges, integer\nranges).\n\n```sql\n-- Enable partition projection on an existing table:\nALTER TABLE \u003Cdb>.\u003Ctable> SET TBLPROPERTIES (\n  'projection.enabled' = 'true',\n  'projection.dt.type' = 'date',\n  'projection.dt.range' = '2024-01-01,2026-12-31',\n  'projection.dt.format' = 'yyyy-MM-dd',\n  'projection.dt.interval' = '1',\n  'projection.dt.interval.unit' = 'DAYS',\n  'storage.location.template' = 's3:\u002F\u002F\u003Cbucket>\u002F\u003Cprefix>\u002F${dt}'\n);\n```\n\nPartition projection eliminates the need for `MSCK REPAIR TABLE` or\n`ALTER TABLE ADD PARTITION` — Athena auto-discovers partitions within the\nconfigured range.\n\n### Step 5: Compression optimization\n\n| Compression | Ratio | Speed | Recommendation |\n|---|---|---|---|\n| None (uncompressed) | 1:1 | Fastest read | Never use for Athena |\n| Snappy | ~3:1 | Fastest decompression | **Default for Parquet** |\n| GZIP | ~4:1 | 2-3x slower than Snappy | Use for cold storage; hurts query speed |\n| ZSTD | ~4:1 | Between Snappy and GZIP | Good for large datasets; level 3-9 |\n| LZ4 | ~2.5:1 | Faster than Snappy | Alternative for latency-sensitive |\n\n**Rule of thumb:** Use Snappy for Parquet (best speed\u002Fratio balance). Avoid\nGZIP for Athena queries — the decompression overhead outweighs the better\ncompression ratio for query workloads. ZSTD is a good upgrade from Snappy for\nvery large datasets where the better ratio reduces S3 GET costs.\n\n### Step 6: Query rewriting\n\n| Pattern | Problem | Fix | Impact |\n|---|---|---|---|\n| `SELECT *` | Reads all columns, even unused | `SELECT col1, col2` (only needed) | 50-90% scan reduction |\n| No WHERE on partition column | Full table scan | `WHERE dt >= '2026-07-01'` | Proportional to partition pruning |\n| `COUNT(DISTINCT col)` | Exact count is expensive | `APPROX_COUNT_DISTINCT(col)` | 10-50x faster, \u003C 3% error |\n| `ORDER BY` without `LIMIT` | Sorts entire dataset | Add `LIMIT N` or use window functions | Reduces sort overhead |\n| `LIKE '%pattern%'` | Full scan, no optimization | Use string functions or pre-process | Variable |\n| Repeated subqueries | Recomputes same data | Use CTE (WITH) or materialize via CTAS | Eliminates redundant scans |\n| `JOIN` on unbucketed large tables | Shuffle-heavy | Bucket both tables on join key (Step 9) | Eliminates shuffle |\n| `UNION` (not `UNION ALL`) | Deduplication overhead | Use `UNION ALL` if no dupes expected | Eliminates sort |\n\n```sql\n-- Before (scans all columns + all partitions):\nSELECT * FROM sales WHERE amount > 100;\n\n-- After (only needed columns + partition filter):\nSELECT order_id, customer_id, amount\nFROM sales\nWHERE dt >= '2026-07-01' AND amount > 100;\n```\n\n### Step 7: CTAS materialization\n\nIf a query (or query pattern) runs frequently and scans a large table to\nproduce a small result, materialize it with CTAS.\n\n**When to use CTAS:**\n- Daily\u002Fweekly aggregation queries scanning raw event data.\n- Complex JOINs that produce a denormalized reporting table.\n- Queries that scan > 100 GB to produce \u003C 1 GB of results.\n\n```sql\n-- Materialize a daily aggregation from raw events:\nCREATE TABLE \u003Cdb>.daily_summary\nWITH (\n  format = 'PARQUET',\n  parquet_compression = 'SNAPPY',\n  partitioned_by = ARRAY['dt'],\n  external_location = 's3:\u002F\u002F\u003Cbucket>\u002Fcurated\u002Fdaily_summary\u002F'\n) AS\nSELECT\n  date_trunc('day', event_time) AS day,\n  product_id,\n  COUNT(*) AS event_count,\n  SUM(amount) AS total_amount\nFROM \u003Cdb>.raw_events\nWHERE dt >= '2026-01-01'\nGROUP BY 1, 2;\n```\n\n**Cost trade-off:** The CTAS itself scans data once (costs $X). Subsequent\nqueries on the materialized table scan far less (costs $X\u002FN per query).\nBreak-even depends on query frequency. If the daily summary is queried 10+\ntimes\u002Fday, CTAS pays for itself within a day.\n\n### Step 8: Workgroup settings\n\n| Setting | Purpose | Recommendation |\n|---|---|---|\n| Data scanned limit (bytes) | Caps worst-case cost per query | Set to p99 of healthy queries × 2 |\n| Query timeout (minutes) | Prevents runaway queries | 30 min for interactive; 6 hours for batch |\n| Requester pays | Shifts cost to query requester | Enable for shared workgroups |\n| Result reuse | Caches identical query results | Enable for dashboard workloads |\n| Enforced workgroup config | Prevents users from bypassing limits | Set `EnforceWorkGroupConfiguration: true` |\n\n```bash\n# Update workgroup with data scanned limit:\naws athena update-work-group \\\n  --work-group \u003Cwg> \\\n  --configuration '{\n    \"ResultConfiguration\": {\"OutputLocation\": \"s3:\u002F\u002F\u003Cbucket>\u002Fresults\u002F\"},\n    \"EnforceWorkGroupConfiguration\": true,\n    \"PublishCloudWatchMetricsEnabled\": true,\n    \"BytesScannedCutoffPerQuery\": 10737418240,\n    \"EngineVersion\": {\"SelectedEngineVersion\": \"Athena engine version 3\"}\n  }'\n```\n\n**Data scanned limit of 10 GB** caps any single query at $0.05. Adjust\nbased on your workload's normal query sizes.\n\n### Step 9: Bucketing for JOIN optimization\n\nBucketing pre-splits data into N files by a hash of the bucket column.\nWhen two tables are bucketed on the same join key with the same bucket\ncount, Athena can perform a bucket-map JOIN without shuffling.\n\n```sql\n-- Create bucketed tables for a large JOIN:\nCREATE TABLE \u003Cdb>.orders_bucketed\nWITH (\n  format = 'PARQUET',\n  parquet_compression = 'SNAPPY',\n  bucketed_by = ARRAY['customer_id'],\n  bucket_count = 256,\n  external_location = 's3:\u002F\u002F\u003Cbucket>\u002Fbucketed\u002Forders\u002F'\n) AS SELECT * FROM \u003Cdb>.orders;\n\nCREATE TABLE \u003Cdb>.customers_bucketed\nWITH (\n  format = 'PARQUET',\n  parquet_compression = 'SNAPPY',\n  bucketed_by = ARRAY['customer_id'],\n  bucket_count = 256,\n  external_location = 's3:\u002F\u002F\u003Cbucket>\u002Fbucketed\u002Fcustomers\u002F'\n) AS SELECT * FROM \u003Cdb>.customers;\n```\n\n**When bucketing helps:** Large-table-to-large-table JOINs (both > 10 GB).\nNot helpful for dimension tables \u003C 1 GB (Athena broadcasts small tables\nautomatically).\n\n### Step 10: Impact estimation and final verdict\n\n```\nFile format savings = (csv_bytes_scanned - parquet_bytes_scanned) * $5\u002FTB * query_freq\nPartition pruning savings = (full_table_scan - partition_scan) * $5\u002FTB * query_freq\nCTAS savings = (raw_scan - materialized_scan) * $5\u002FTB * query_freq - ctas_creation_cost\n```\n\nVerdict: any dimension with a concrete recommendation → **OPPORTUNITY_FOUND**.\nAll dimensions pass → **ALREADY_OPTIMAL**. Changes applied and verified →\n**OPTIMIZED**.\n\n## Output format\n\nSee STRICT output contract above. Worked example below. Additional examples\n(CSV to Parquet migration, ALREADY_OPTIMAL, NEED_MORE_INFO) in\n`references\u002Fathena-optimization-reference.md`.\n\n### Worked example — CSV to Parquet + partitioning + workgroup limit\n\n```text\nTARGET: analytics_db.events_raw\nVERDICT: OPPORTUNITY_FOUND\nREASON: Table is unpartitioned CSV (1.2 TB). Top 10 queries scan the full\n  table averaging 320s runtime. Migrating to Parquet + partitioning by date\n  reduces average scan from 1.2 TB to 18 GB (daily queries). Adding a 10 GB\n  data-scanned limit prevents runaway scans.\nRECOMMENDATION:\n  Current: CSV, unpartitioned, no compression, no workgroup limit\n  Proposed: Parquet + Snappy, partitioned by dt, 10 GB workgroup limit\n  File format: CSV → Parquet\n  Compression: none → Snappy\n  Partitioning: none → partitioned_by = ['dt']\n  Query rewrite: SELECT * → SELECT 8 of 42 columns; add WHERE dt filter\n  Workgroup: no limit → 10 GB data scanned per query\n  CTAS: materialize daily_summary aggregation table\n  Confidence: HIGH — DDL confirms CSV\u002Funpartitioned, query history shows\n    daily date-filtered queries scanning 1.2 TB each.\nESTIMATED_SAVINGS:\n  Cost (monthly): $3,280.50 → $49.10\n    (1.2 TB × $5 × 220 queries\u002Fmonth → 18 GB × $5 × 220 queries\u002Fmonth)\n  Performance: 320s avg → 8s avg (40x faster)\n  Data scanned per query: 1.2 TB → 18 GB (98.5% reduction)\n  Annual total: $38,774.40\n  Assumptions: $5\u002FTB, 220 daily-filtered queries\u002Fmonth, 1\u002F30th data per\n    partition after date partitioning + columnar pruning.\nMIGRATION_STEPS:\n  1. Create the Parquet partitioned table via CTAS:\n     CREATE TABLE analytics_db.events_parquet\n     WITH (format='PARQUET', parquet_compression='SNAPPY',\n           partitioned_by=ARRAY['dt'],\n           external_location='s3:\u002F\u002F\u003Cbucket>\u002Fevents\u002Fparquet\u002F')\n     AS SELECT event_id, user_id, event_type, amount, device, country,\n       ip_address, session_id,\n       date_format(event_time, '%Y-%m-%d') AS dt\n     FROM analytics_db.events_raw;\n  2. Verify row count parity:\n     SELECT COUNT(*) FROM analytics_db.events_parquet;\n     SELECT COUNT(*) FROM analytics_db.events_raw;\n  3. Update downstream queries to use the new table + partition filter:\n     SELECT event_type, COUNT(*) FROM analytics_db.events_parquet\n     WHERE dt >= '2026-07-01' GROUP BY event_type;\n  4. Set the workgroup data-scanned limit:\n     aws athena update-work-group --work-group primary \\\n       --configuration '{\"BytesScannedCutoffPerQuery\":10737418240,...}'\n  5. Monitor query performance for 7 days before decommissioning the CSV table.\nCONFIRM: Before running the CTAS (scans 1.2 TB, cost ~$6.00), emit and await:\n  \"CONFIRM: About to run CTAS migration on analytics_db.events_raw (1.2 TB,\n   estimated cost $6.00). Proceed? (yes\u002Fno)\"\n```\n\n## Verdict semantics\n\n| Verdict | When to emit |\n|---|---|\n| OPPORTUNITY_FOUND | At least one dimension has a concrete, savings-bearing recommendation. |\n| OPTIMIZED | Changes applied and verified this session; queries confirm improvement. |\n| ALREADY_OPTIMAL | Parquet + partitioned + tight queries + workgroup limits in place. |\n\n## Expert heuristic — consolidated\n\nFull heuristic table (cost lever is bytes scanned, columnar pruning, partition pruning, partition projection, Snappy vs GZIP, APPROX_COUNT_DISTINCT, CTAS break-even, workgroup limits, engine v3 dynamic partition pruning, result reuse, federated pricing, small files): [Advanced patterns](references\u002Fadvanced-patterns.md).\n\n## NEVER (top 5)\n\n- **NEVER** recommend changing query patterns without first checking the file\n  format. A `SELECT *` on Parquet is still better than `SELECT *` on CSV, but\n  `SELECT col1, col2` on CSV is still expensive. Fix file format first.\n\n- **NEVER** recommend partitioning without estimating partition size. Too\n  many small partitions (\u003C 100 MB each) cause S3 503 errors and metadata\n  bloat. Consolidate to daily or monthly partitions if hourly files are small.\n\n- **NEVER** recommend GZIP compression for Athena Parquet tables. GZIP's\n  decompression overhead negates the compression advantage for query\n  workloads. Use Snappy (default) or ZSTD.\n\n- **NEVER** set a workgroup data-scanned limit without first measuring normal\n  query sizes. Setting it too low blocks legitimate queries. Measure p99\n  first, then set limit at p99 × 2.\n\n- **NEVER** recommend CTAS materialization without checking query frequency.\n  A CTAS that costs $5 to create but is queried once\u002Fmonth does not break\n  even. Materialize only if query frequency justifies the one-time cost.\n\n## Pre-flight safety checks (run before any remediation)\n\n- **MANDATORY CONFIRMATION GATE** before any CTAS (it scans data and costs $).\n- **Verify row count parity** after CTAS migration before decommissioning\n  the source table.\n- **Verify partition count** after adding partition projection — if the\n  projection range is wrong, Athena may miss partitions.\n- **Batch limit:** max 5 table migrations per batch, single CONFIRM per batch.\n- **Capture pre-state:** record current DDL and query history before changes.\n\n## Recent AWS features (2024-2026)\n\nRecent AWS features (result reuse, federated queries, Spark notebooks, engine v3, Iceberg, parameterized queries): [Advanced patterns](references\u002Fadvanced-patterns.md).\n\n## References (load on demand)\n\n- [Advanced patterns](references\u002Fadvanced-patterns.md) — consolidated expert-heuristic table (non-obvious Athena behaviours) and recent AWS features (result reuse, federated queries, Spark notebooks, engine v3, Iceberg, parameterized queries)\n- [Diagnostic commands](references\u002Fdiagnostic-commands.md) — Step 1 data-gathering CLI (Glue DDL, query history, batch-get execution statistics)\n- `references\u002Fathena-optimization-reference.md` — pre-flight CLI sequences, CTAS templates, partition projection configs, workgroup commands, cost formulas, additional worked examples, full NEVER list\n- `references\u002Ffailure-decision-tree.md` — per-step worked examples and the cross-category decision flowchart\n\n## Domain\n\nAWS CloudOps \u002F Amazon Athena Analytics Query Performance & Cost Optimization.\n\n## AWS documentation\n\n- **Amazon Athena User Guide** — https:\u002F\u002Fdocs.aws.amazon.com\u002Fathena\u002Flatest\u002Fug\u002Fwhat-is.html\n- **Athena performance tuning** — https:\u002F\u002Fdocs.aws.amazon.com\u002Fathena\u002Flatest\u002Fug\u002Fperformance-tuning.html\n- **Athena pricing** — https:\u002F\u002Faws.amazon.com\u002Fathena\u002Fpricing\u002F\n- **Athena CTAS** — https:\u002F\u002Fdocs.aws.amazon.com\u002Fathena\u002Flatest\u002Fug\u002Fctas.html\n- **Partition projection** — https:\u002F\u002Fdocs.aws.amazon.com\u002Fathena\u002Flatest\u002Fug\u002Fpartition-projection.html\n- **Athena query result reuse** — https:\u002F\u002Fdocs.aws.amazon.com\u002Fathena\u002Flatest\u002Fug\u002Fquery-result-reuse.html\n- **Athena federated queries** — https:\u002F\u002Fdocs.aws.amazon.com\u002Fathena\u002Flatest\u002Fug\u002Fconnect-to-a-data-source.html\n- **Athena Spark** — https:\u002F\u002Fdocs.aws.amazon.com\u002Fathena\u002Flatest\u002Fug\u002Fnotebooks-spark.html\n- **Apache Iceberg on Athena** — https:\u002F\u002Fdocs.aws.amazon.com\u002Fathena\u002Flatest\u002Fug\u002Fquerying-iceberg.html\n- **AWS Well-Architected Framework — Performance Efficiency** — https:\u002F\u002Fdocs.aws.amazon.com\u002Fwellarchitected\u002Flatest\u002Fperformance-efficiency-pillar\u002Fwelcome.html\n",{"name":5,"license":15,"metadata":24,"description":7,"compatibility":43},{"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,"activation_triggers":42},"aws, athena, analytics, optimize, query-performance, cost-optimization, partitioning, parquet","3","Jacky Chan — AWS Community Builder","aws-cloudops","Analytics","0.1.0","Athena, query optimization, partitioning, partition projection, Parquet, columnar format, Snappy, compression, bucketing, workgroup, data scanned, CTAS, materialization, SELECT *, APPROXIMATE, $5\u002FTB, result reuse, federated queries, Spark notebook","optimize","high","false","capability","Optimizing Athena query performance and cost: reducing data scanned via partitioning and columnar formats, setting up partition projection, evaluating CTAS for materialization, tuning workgroup settings (data scanned limits, query timeout), rewriting queries (avoid SELECT *, add partition filters, use APPROXIMATE functions), or planning a file format migration from CSV\u002FJSON to Parquet.","true","OPTIMIZED | OPPORTUNITY_FOUND | ALREADY_OPTIMAL","Troubleshooting Athena query failures (use a troubleshoot skill), auditing Athena workgroup security (use the audit-athena-workgroup skill), building a data lake from scratch (use a deploy skill), or Athena Glue crawler troubleshooting (use a Glue troubleshoot skill). This skill focuses on performance and cost optimization.","active","Input: either (a) an Athena query or workload description with table DDL and query patterns, OR (b) live-account context with workgroup, database, table, and query history. Output: a deterministic TARGET \u002F VERDICT \u002F REASON \u002F RECOMMENDATION \u002F ESTIMATED_SAVINGS \u002F MIGRATION_STEPS block where VERDICT is one of {OPTIMIZED, OPPORTUNITY_FOUND, ALREADY_OPTIMAL} and RECOMMENDATION includes file format, partitioning strategy, query rewrite, workgroup config, and materialization (CTAS) guidance.","optimize Athena query, Athena query slow, Athena cost reduction, Athena partition projection, Athena file format Parquet, Athena CTAS optimization, Athena data scanned limit, Athena workgroup settings, Athena SELECT * optimization, Athena $5\u002FTB scanned, Athena result reuse, Athena federated query, reduce Athena spend, Athena query timeout, Athena bucketing","Agent runtime that reads SKILL.md (Claude Code, Cursor, Windsurf, Codex, Gemini). Offline recommendation classification works from pasted DDL, EXPLAIN output, and query history. Live-account optimization uses aws athena get-query-execution, start-query-execution, batch-get-query-execution, get-work-group, aws ce get-cost-and-usage for Athena spend, aws glue get-table, get-partitions for table metadata, and aws s3 ls for data lake layout inspection (AWS CLI v2, SSO or key-based credentials).","main","eeace51bd5dd1db2030729d83eeab988861553aa","skills\u002Fathena-query-optimizer",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":53,"prompt":63,"zipAvailable":64},[54,57,60],{"tool":55,"command":56},"npx","npx skills add jhkchan\u002Faws-agent-skills --skill athena-query-optimizer",{"tool":58,"command":59},"bunx","bunx skills add jhkchan\u002Faws-agent-skills --skill athena-query-optimizer",{"tool":61,"command":62},"pnpm","pnpm dlx skills add jhkchan\u002Faws-agent-skills --skill athena-query-optimizer","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fathena-query-optimizer\u002FSKILL.md",true,[66,72,76,80,84,88,92,96,100,104,108,112,116,120,124,128,132,136,140],{"path":67,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":70,"sourceHtmlUrl":71},"eval\u002Ftest-cases.yaml","REFERENCE","参考文档",9423,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fathena-query-optimizer\u002Feval\u002Ftest-cases.yaml",{"path":73,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":74,"sourceHtmlUrl":75},"evals\u002Fbaselines\u002Falready-optimal-parquet-partitioned-projection.md",590,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fathena-query-optimizer\u002Fevals\u002Fbaselines\u002Falready-optimal-parquet-partitioned-projection.md",{"path":77,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":78,"sourceHtmlUrl":79},"evals\u002Fbaselines\u002Fcsv-to-parquet-migration.md",859,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fathena-query-optimizer\u002Fevals\u002Fbaselines\u002Fcsv-to-parquet-migration.md",{"path":81,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":82,"sourceHtmlUrl":83},"evals\u002Fbaselines\u002Fctas-materialization-repeated-scan.md",696,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fathena-query-optimizer\u002Fevals\u002Fbaselines\u002Fctas-materialization-repeated-scan.md",{"path":85,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":86,"sourceHtmlUrl":87},"evals\u002Fbaselines\u002Fpartition-projection-large-partition-count.md",701,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fathena-query-optimizer\u002Fevals\u002Fbaselines\u002Fpartition-projection-large-partition-count.md",{"path":89,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":90,"sourceHtmlUrl":91},"evals\u002Fbaselines\u002Fquery-rewrite-select-star.md",654,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fathena-query-optimizer\u002Fevals\u002Fbaselines\u002Fquery-rewrite-select-star.md",{"path":93,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":94,"sourceHtmlUrl":95},"evals\u002Feval_config.yaml",1890,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fathena-query-optimizer\u002Fevals\u002Feval_config.yaml",{"path":97,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":98,"sourceHtmlUrl":99},"evals\u002Fevals.json",4577,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fathena-query-optimizer\u002Fevals\u002Fevals.json",{"path":101,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":102,"sourceHtmlUrl":103},"evals\u002Fprompts\u002Falready-optimal-parquet-partitioned-projection.md",1537,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fathena-query-optimizer\u002Fevals\u002Fprompts\u002Falready-optimal-parquet-partitioned-projection.md",{"path":105,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":106,"sourceHtmlUrl":107},"evals\u002Fprompts\u002Fcsv-to-parquet-migration.md",1311,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fathena-query-optimizer\u002Fevals\u002Fprompts\u002Fcsv-to-parquet-migration.md",{"path":109,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":110,"sourceHtmlUrl":111},"evals\u002Fprompts\u002Fctas-materialization-repeated-scan.md",1479,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fathena-query-optimizer\u002Fevals\u002Fprompts\u002Fctas-materialization-repeated-scan.md",{"path":113,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":114,"sourceHtmlUrl":115},"evals\u002Fprompts\u002Fpartition-projection-large-partition-count.md",1289,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fathena-query-optimizer\u002Fevals\u002Fprompts\u002Fpartition-projection-large-partition-count.md",{"path":117,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":118,"sourceHtmlUrl":119},"evals\u002Fprompts\u002Fquery-rewrite-select-star.md",1569,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fathena-query-optimizer\u002Fevals\u002Fprompts\u002Fquery-rewrite-select-star.md",{"path":121,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":122,"sourceHtmlUrl":123},"examples\u002FREADME.md",5552,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fathena-query-optimizer\u002Fexamples\u002FREADME.md",{"path":125,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":126,"sourceHtmlUrl":127},"references\u002Fadvanced-patterns.md",3126,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fathena-query-optimizer\u002Freferences\u002Fadvanced-patterns.md",{"path":129,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":130,"sourceHtmlUrl":131},"references\u002Fathena-optimization-reference.md",11183,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fathena-query-optimizer\u002Freferences\u002Fathena-optimization-reference.md",{"path":133,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":134,"sourceHtmlUrl":135},"references\u002Fdiagnostic-commands.md",878,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fathena-query-optimizer\u002Freferences\u002Fdiagnostic-commands.md",{"path":137,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":138,"sourceHtmlUrl":139},"references\u002Ffailure-decision-tree.md",9243,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fathena-query-optimizer\u002Freferences\u002Ffailure-decision-tree.md",{"path":141,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":142,"sourceHtmlUrl":143},"skill.usf.yaml",4624,"https:\u002F\u002Fgithub.com\u002Fjhkchan\u002Faws-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fathena-query-optimizer\u002Fskill.usf.yaml",[145,152,159,166,173,180],{"skillNo":146,"name":147,"nameZh":6,"description":148,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":149,"categories":150,"keywords":151,"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":153,"name":154,"nameZh":6,"description":155,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":156,"categories":157,"keywords":158,"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":160,"name":161,"nameZh":6,"description":162,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":163,"categories":164,"keywords":165,"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":167,"name":168,"nameZh":6,"description":169,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":170,"categories":171,"keywords":172,"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":174,"name":175,"nameZh":6,"description":176,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":177,"categories":178,"keywords":179,"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":181,"name":182,"nameZh":6,"description":183,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":184,"categories":185,"keywords":186,"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",[],[]]