[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M74D9STAS0CVQZJ60MAR336W":3,"skill-same:01M74D9STAS0CVQZJ60MAR336W":56},{"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":26,"commitSha":27,"skillDirectory":28,"forksCount":29,"repositoryHtmlUrl":30,"repositoryHomepageUrl":31,"ownerHtmlUrl":32,"ownerBlogUrl":33,"ownerDescription":34,"updatedAt":35,"install":36,"resources":49},"01M74D9STAS0CVQZJ60MAR336W","pg-stat-statements-observability",null,"pg_stat_statements Query Observability","CarlosCaPe\u002Foctorato","CarlosCaPe","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F39838249?v=4","01M72WXX4ZRR8MBH1EP1QND2FQ","dataqbs","01M72WXX5NA7YCKRSJ54GW1GQ8",18,"MIT","https:\u002F\u002Fgithub.com\u002FCarlosCaPe\u002Foctorato\u002Fblob\u002Fmaster\u002Fskills\u002Fpg-stat-statements-observability\u002FSKILL.md",[],[],"2026-11-11 15:11:14",false,"---\nname: pg-stat-statements-observability\ndescription: \"pg_stat_statements Query Observability\"\nmetadata:\n  short-description: \"pg_stat_statements Query Observability\"\n  original-index: 33\n---\n\n# pg_stat_statements Query Observability\n\n> Source: [PostgreSQL Best Practices](..\u002FDOCUMENTS\u002FPostgreSQL_BestPractices_Azure.md)\n> -- \"Server configuration\", \n\n## What\n\nEnabling and using the `pg_stat_statements` extension to capture per-query\nperformance metrics (calls, total time, mean time, rows, shared blocks).\nThis is the primary tool for identifying slow queries, regression, and\noptimization opportunities.\n\n## Why\n\nWithout query-level metrics:\n- Slow queries hide behind aggregate server metrics (CPU, IOPS)\n- Index optimization is guesswork -- you cannot tell which queries dominate\n- Performance regressions after deployments go undetected\n- Capacity planning has no data foundation\n\n`pg_stat_statements` is lightweight (\u003C 1% overhead), built into PostgreSQL,\nand available on Azure Flexible Server as a loadable module.\n\n## How\n\n### Enable the extension (Azure Flexible Server)\n\n1. Azure Portal > Server Parameters:\n   ```text\n   shared_preload_libraries = pg_stat_statements   -- requires restart\n   pg_stat_statements.track = all                  -- track all statements\n   pg_stat_statements.max = 5000                   -- max tracked queries\n   ```\n2. Restart the server (required for `shared_preload_libraries`).\n3. Create the extension in each database:\n   ```sql\n   CREATE EXTENSION IF NOT EXISTS pg_stat_statements;\n   ```\n\n### Top 10 queries by total execution time\n\n```sql\nSELECT\n    calls,\n    ROUND(total_exec_time::numeric, 2)       AS total_ms,\n    ROUND(mean_exec_time::numeric, 2)        AS mean_ms,\n    ROUND(min_exec_time::numeric, 2)         AS min_ms,\n    ROUND(max_exec_time::numeric, 2)         AS max_ms,\n    rows,\n    LEFT(query, 120)                         AS query_preview\nFROM pg_stat_statements\nORDER BY total_exec_time DESC\nLIMIT 10;\n```\n\n### Top 10 queries by mean execution time (slow outliers)\n\n```sql\nSELECT\n    calls,\n    ROUND(mean_exec_time::numeric, 2)        AS mean_ms,\n    ROUND(total_exec_time::numeric, 2)       AS total_ms,\n    rows,\n    LEFT(query, 120)                         AS query_preview\nFROM pg_stat_statements\nWHERE calls > 10                             -- ignore one-off admin queries\nORDER BY mean_exec_time DESC\nLIMIT 10;\n```\n\n### Top 10 queries by shared buffer reads (I\u002FO heavy)\n\n```sql\nSELECT\n    calls,\n    shared_blks_read + shared_blks_hit       AS total_blks,\n    ROUND(\n        100.0 * shared_blks_hit \u002F\n        NULLIF(shared_blks_read + shared_blks_hit, 0), 2\n    )                                        AS cache_hit_pct,\n    ROUND(mean_exec_time::numeric, 2)        AS mean_ms,\n    LEFT(query, 120)                         AS query_preview\nFROM pg_stat_statements\nORDER BY shared_blks_read DESC\nLIMIT 10;\n```\n\n### Reset statistics (after optimization to re-baseline)\n\n```sql\n-- Reset ALL query stats (use sparingly)\nSELECT pg_stat_statements_reset();\n```\n\n### Check if extension is active\n\n```sql\nSELECT * FROM pg_available_extensions\nWHERE name = 'pg_stat_statements';\n\n-- If installed, verify it is tracking\nSELECT COUNT(*) AS tracked_queries\nFROM pg_stat_statements;\n```\n\n### Combine with slow query logging\n\n```text\n-- Server parameter (Azure Portal)\nlog_min_duration_statement = 250    -- log queries > 250ms\n\n-- This gives you two layers:\n-- 1. pg_stat_statements: aggregated stats for ALL queries\n-- 2. PostgreSQL log: individual slow query events with parameters\n```\n\n## Key Metrics to Monitor\n\n| Metric | What It Tells You | Action Threshold |\n|--------|------------------|-----------------|\n| `total_exec_time` | Cumulative CPU cost | Top query > 50% of total |\n| `mean_exec_time` | Per-call latency | > 100ms for OLTP queries |\n| `calls` | Query frequency | Top query > 10K calls\u002Fhour |\n| `rows` | Rows returned per call | > 10K rows (missing pagination?) |\n| `shared_blks_read` | Disk I\u002FO | High reads = missing index or seq scan |\n| `cache_hit_pct` | Buffer cache effectiveness | \u003C 95% = under-provisioned memory |\n\n## When to Use\n\n- After enabling on a new server  pattern)\n- Before and after index changes to measure impact\n- During audit investigations to find optimization targets\n- Periodically (weekly\u002Fmonthly) for capacity planning\n\n## Where We Used It\n\n- ****: Enabled `pg_stat_statements` on DEV and QA servers\n- **Best Practices**: Listed as mandatory server configuration\n- **Audit TDDs**: Query-level observability requirement\n\n## Related Skills\n\n- **Skill #29** (EXPLAIN ANALYZE) -- detailed plan for individual queries\n- **Skill #30** (Autovacuum & Bloat) -- bloat causes seq scans, visible here\n- **Skill #32** (Connection Pooling) -- slow queries identified here, timeouts set there\n\n## References\n\n- [PostgreSQL Best Practices](..\u002FDOCUMENTS\u002FPostgreSQL_BestPractices_Azure.md)\n  -- \"Server configuration\" section\n- [User Management Audit TDD](..\u002FDOCUMENTS\u002Fuser_mgmt_DB_Audit_TDD.md)\n  -- \"Query-level observability\" requirement\n\n## Gotchas\n\n- `shared_preload_libraries` change requires a **server restart** on Azure\n  Flexible Server -- coordinate with ops\n- Statistics persist across connections but are lost on server restart\n  unless `pg_stat_statements.save = on` (default on Azure)\n- `pg_stat_statements_reset()` clears ALL stats -- there is no per-query\n  reset; use it only after a known baseline change\n- The `query` column normalizes literal values to `$1, $2, ...` -- you\n  cannot see actual parameter values (by design, for security)\n- `pg_stat_statements.max = 5000` means the 5001st unique query evicts\n  the least-used entry -- increase if your app has many dynamic queries\n- On Azure, you may need the `azure_pg_admin` role to create the extension\n\n---\n\n*Category: Tooling | Origin: *\n","# pg_stat_statements Query Observability\n\n> Source: [PostgreSQL Best Practices](..\u002FDOCUMENTS\u002FPostgreSQL_BestPractices_Azure.md)\n> -- \"Server configuration\", \n\n## What\n\nEnabling and using the `pg_stat_statements` extension to capture per-query\nperformance metrics (calls, total time, mean time, rows, shared blocks).\nThis is the primary tool for identifying slow queries, regression, and\noptimization opportunities.\n\n## Why\n\nWithout query-level metrics:\n- Slow queries hide behind aggregate server metrics (CPU, IOPS)\n- Index optimization is guesswork -- you cannot tell which queries dominate\n- Performance regressions after deployments go undetected\n- Capacity planning has no data foundation\n\n`pg_stat_statements` is lightweight (\u003C 1% overhead), built into PostgreSQL,\nand available on Azure Flexible Server as a loadable module.\n\n## How\n\n### Enable the extension (Azure Flexible Server)\n\n1. Azure Portal > Server Parameters:\n   ```text\n   shared_preload_libraries = pg_stat_statements   -- requires restart\n   pg_stat_statements.track = all                  -- track all statements\n   pg_stat_statements.max = 5000                   -- max tracked queries\n   ```\n2. Restart the server (required for `shared_preload_libraries`).\n3. Create the extension in each database:\n   ```sql\n   CREATE EXTENSION IF NOT EXISTS pg_stat_statements;\n   ```\n\n### Top 10 queries by total execution time\n\n```sql\nSELECT\n    calls,\n    ROUND(total_exec_time::numeric, 2)       AS total_ms,\n    ROUND(mean_exec_time::numeric, 2)        AS mean_ms,\n    ROUND(min_exec_time::numeric, 2)         AS min_ms,\n    ROUND(max_exec_time::numeric, 2)         AS max_ms,\n    rows,\n    LEFT(query, 120)                         AS query_preview\nFROM pg_stat_statements\nORDER BY total_exec_time DESC\nLIMIT 10;\n```\n\n### Top 10 queries by mean execution time (slow outliers)\n\n```sql\nSELECT\n    calls,\n    ROUND(mean_exec_time::numeric, 2)        AS mean_ms,\n    ROUND(total_exec_time::numeric, 2)       AS total_ms,\n    rows,\n    LEFT(query, 120)                         AS query_preview\nFROM pg_stat_statements\nWHERE calls > 10                             -- ignore one-off admin queries\nORDER BY mean_exec_time DESC\nLIMIT 10;\n```\n\n### Top 10 queries by shared buffer reads (I\u002FO heavy)\n\n```sql\nSELECT\n    calls,\n    shared_blks_read + shared_blks_hit       AS total_blks,\n    ROUND(\n        100.0 * shared_blks_hit \u002F\n        NULLIF(shared_blks_read + shared_blks_hit, 0), 2\n    )                                        AS cache_hit_pct,\n    ROUND(mean_exec_time::numeric, 2)        AS mean_ms,\n    LEFT(query, 120)                         AS query_preview\nFROM pg_stat_statements\nORDER BY shared_blks_read DESC\nLIMIT 10;\n```\n\n### Reset statistics (after optimization to re-baseline)\n\n```sql\n-- Reset ALL query stats (use sparingly)\nSELECT pg_stat_statements_reset();\n```\n\n### Check if extension is active\n\n```sql\nSELECT * FROM pg_available_extensions\nWHERE name = 'pg_stat_statements';\n\n-- If installed, verify it is tracking\nSELECT COUNT(*) AS tracked_queries\nFROM pg_stat_statements;\n```\n\n### Combine with slow query logging\n\n```text\n-- Server parameter (Azure Portal)\nlog_min_duration_statement = 250    -- log queries > 250ms\n\n-- This gives you two layers:\n-- 1. pg_stat_statements: aggregated stats for ALL queries\n-- 2. PostgreSQL log: individual slow query events with parameters\n```\n\n## Key Metrics to Monitor\n\n| Metric | What It Tells You | Action Threshold |\n|--------|------------------|-----------------|\n| `total_exec_time` | Cumulative CPU cost | Top query > 50% of total |\n| `mean_exec_time` | Per-call latency | > 100ms for OLTP queries |\n| `calls` | Query frequency | Top query > 10K calls\u002Fhour |\n| `rows` | Rows returned per call | > 10K rows (missing pagination?) |\n| `shared_blks_read` | Disk I\u002FO | High reads = missing index or seq scan |\n| `cache_hit_pct` | Buffer cache effectiveness | \u003C 95% = under-provisioned memory |\n\n## When to Use\n\n- After enabling on a new server  pattern)\n- Before and after index changes to measure impact\n- During audit investigations to find optimization targets\n- Periodically (weekly\u002Fmonthly) for capacity planning\n\n## Where We Used It\n\n- ****: Enabled `pg_stat_statements` on DEV and QA servers\n- **Best Practices**: Listed as mandatory server configuration\n- **Audit TDDs**: Query-level observability requirement\n\n## Related Skills\n\n- **Skill #29** (EXPLAIN ANALYZE) -- detailed plan for individual queries\n- **Skill #30** (Autovacuum & Bloat) -- bloat causes seq scans, visible here\n- **Skill #32** (Connection Pooling) -- slow queries identified here, timeouts set there\n\n## References\n\n- [PostgreSQL Best Practices](..\u002FDOCUMENTS\u002FPostgreSQL_BestPractices_Azure.md)\n  -- \"Server configuration\" section\n- [User Management Audit TDD](..\u002FDOCUMENTS\u002Fuser_mgmt_DB_Audit_TDD.md)\n  -- \"Query-level observability\" requirement\n\n## Gotchas\n\n- `shared_preload_libraries` change requires a **server restart** on Azure\n  Flexible Server -- coordinate with ops\n- Statistics persist across connections but are lost on server restart\n  unless `pg_stat_statements.save = on` (default on Azure)\n- `pg_stat_statements_reset()` clears ALL stats -- there is no per-query\n  reset; use it only after a known baseline change\n- The `query` column normalizes literal values to `$1, $2, ...` -- you\n  cannot see actual parameter values (by design, for security)\n- `pg_stat_statements.max = 5000` means the 5001st unique query evicts\n  the least-used entry -- increase if your app has many dynamic queries\n- On Azure, you may need the `azure_pg_admin` role to create the extension\n\n---\n\n*Category: Tooling | Origin: *\n",{"name":5,"metadata":24,"description":7},{"original-index":25,"short-description":7},33,"master","b4414608cd5a3f87d1525b518f1c6add8363540d","skills\u002Fpg-stat-statements-observability",6,"https:\u002F\u002Fgithub.com\u002FCarlosCaPe\u002Foctorato","https:\u002F\u002Fwww.dataqbs.com\u002Foctorato","https:\u002F\u002Fgithub.com\u002FCarlosCaPe","www.dataqbs.com"," AI-powered data engineering\r\n& consulting\r\n\r\nWe build data platforms that turn complexity into clarity — from cloud architecture and ETL pipelines to AI-driven","2026-11-14 00:21:00",{"source":8,"skillName":5,"commands":37,"prompt":47,"zipAvailable":48},[38,41,44],{"tool":39,"command":40},"npx","npx skills add CarlosCaPe\u002Foctorato --skill pg-stat-statements-observability",{"tool":42,"command":43},"bunx","bunx skills add CarlosCaPe\u002Foctorato --skill pg-stat-statements-observability",{"tool":45,"command":46},"pnpm","pnpm dlx skills add CarlosCaPe\u002Foctorato --skill pg-stat-statements-observability","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FCarlosCaPe\u002Foctorato\u002Fblob\u002Fmaster\u002Fskills\u002Fpg-stat-statements-observability\u002FSKILL.md",true,[50],{"path":51,"resourceType":52,"resourceTypeDesc":53,"sizeBytes":54,"sourceHtmlUrl":55},"skill.json","REFERENCE","参考文档",169,"https:\u002F\u002Fgithub.com\u002FCarlosCaPe\u002Foctorato\u002Fblob\u002Fmaster\u002Fskills\u002Fpg-stat-statements-observability\u002Fskill.json",[57,66,74,81,89,97],{"skillNo":58,"name":59,"nameZh":6,"description":60,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":61,"licenseFileUrl":62,"sourceHtmlUrl":63,"categories":64,"keywords":65,"publishedAt":19},"01M74EVAA4A4B4AKR5TT732GP4","yeet","Use only when the user explicitly asks to stage, commit, push, and open a GitHub pull request in one flow using the GitHub CLI (`gh`).","Apache-2.0","https:\u002F\u002Fgithub.com\u002FCarlosCaPe\u002Foctorato\u002Fblob\u002Fmaster\u002Fskills\u002Fyeet\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002FCarlosCaPe\u002Foctorato\u002Fblob\u002Fmaster\u002Fskills\u002Fyeet\u002FSKILL.md",[],[],{"skillNo":67,"name":68,"nameZh":6,"description":69,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":61,"licenseFileUrl":70,"sourceHtmlUrl":71,"categories":72,"keywords":73,"publishedAt":19},"01M74EV4WMRDKP2NQS4YWR8PXH","wrangler","Cloudflare Workers CLI for deploying, developing, and managing Workers, KV, R2, D1, Vectorize, Hyperdrive, Workers AI, Containers, Queues, Workflows, Pipelines, and Secrets Store. Load before running wrangler commands to ensure correct syntax and best practices. Biases towards retrieval from Cloudflare docs over pre-trained knowledge.","https:\u002F\u002Fgithub.com\u002FCarlosCaPe\u002Foctorato\u002Fblob\u002Fmaster\u002Fskills\u002Fwrangler\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FCarlosCaPe\u002Foctorato\u002Fblob\u002Fmaster\u002Fskills\u002Fwrangler\u002FSKILL.md",[],[],{"skillNo":75,"name":76,"nameZh":6,"description":77,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":78,"categories":79,"keywords":80,"publishedAt":19},"01M74EV05MHTXKEXD4B2QJEYTF","workspace-skill-discovery","Discover and include ALL skills across the workspace — not just global ones. Use at the start of every session or when the user asks about available skills. Ensures project-level skills (under .claude\u002Fskills\u002F or skills\u002F in any repo) are never missed.","https:\u002F\u002Fgithub.com\u002FCarlosCaPe\u002Foctorato\u002Fblob\u002Fmaster\u002Fskills\u002Fworkspace-skill-discovery\u002FSKILL.md",[],[],{"skillNo":82,"name":83,"nameZh":6,"description":84,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":61,"licenseFileUrl":85,"sourceHtmlUrl":86,"categories":87,"keywords":88,"publishedAt":19},"01M74ETV78525B4VP2F28Z6NRD","workers-best-practices","Reviews and authors Cloudflare Workers code against production best practices. Load when writing new Workers, reviewing Worker code, configuring wrangler.jsonc, or checking for common Workers anti-patterns (streaming, floating promises, global state, secrets, bindings, observability). Biases towards retrieval from Cloudflare docs over pre-trained knowledge.","https:\u002F\u002Fgithub.com\u002FCarlosCaPe\u002Foctorato\u002Fblob\u002Fmaster\u002Fskills\u002Fworkers-best-practices\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FCarlosCaPe\u002Foctorato\u002Fblob\u002Fmaster\u002Fskills\u002Fworkers-best-practices\u002FSKILL.md",[],[],{"skillNo":90,"name":91,"nameZh":6,"description":92,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":61,"licenseFileUrl":93,"sourceHtmlUrl":94,"categories":95,"keywords":96,"publishedAt":19},"01M74ETR75NF67WGVEN7288ACV","winui-app","Create, build and design WinUI 3 desktop apps with C# and the Windows App SDK following Microsoft's official guidance and CommunityToolkit. Covers XAML, navigation, theming, accessibility and deployment.","https:\u002F\u002Fgithub.com\u002FCarlosCaPe\u002Foctorato\u002Fblob\u002Fmaster\u002Fskills\u002Fwinui-app\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002FCarlosCaPe\u002Foctorato\u002Fblob\u002Fmaster\u002Fskills\u002Fwinui-app\u002FSKILL.md",[],[],{"skillNo":98,"name":99,"nameZh":6,"description":100,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":101,"categories":102,"keywords":103,"publishedAt":19},"01M74ETJFRNPPNSQZ36C6HD6CW","windows-brain-script-portability","Scripts in ~\u002F.claude\u002Fscripts\u002F that run on a Windows brain: use the python3.cmd shim and not bare python3, and reconfigure stdout to UTF-8 if you print symbols. Use it when writing a brain script or triaging a Windows-only crash.","https:\u002F\u002Fgithub.com\u002FCarlosCaPe\u002Foctorato\u002Fblob\u002Fmaster\u002Fskills\u002Fwindows-brain-script-portability\u002FSKILL.md",[],[]]