{
  "id": "tpl_abeb2631b051",
  "slug": "postgres-slow-query-index-advisor",
  "asset_type": "template",
  "name": "PostgreSQL pg_stat_statements Index Advisor",
  "tagline": "Queries `pg_stat_statements` on read replicas to identify sequential scans and high-mean-time queries, then benchmarks candidate B-Tree/GIN indexes on a Ne",
  "description_md": "### Overview & Operational Goal\n**PostgreSQL pg_stat_statements Index Advisor** (`postgres-slow-query-index-advisor`) is a verified Grok Bot template designed and tested with **@cloudflare** ([`x.com/cloudflare`](https://x.com/cloudflare)).\n\nQueries `pg_stat_statements` on read replicas to identify sequential scans and high-mean-time queries, then benchmarks candidate B-Tree/GIN indexes on a Neon branch.\n\n### Required MCP Connectors & Permissions\n- **Required Connectors:** Postgres MCP, Neon MCP, Slack MCP\n- **Routine / Trigger Schedule:** `0 6 * * 2,4 (6:00 AM Tue/Thu)`\n- **Safety & Approval Boundary:** **Ask-First / Human-in-the-Loop** — never executes irreversible external sends, destructive deletions, or financial transactions without explicit user approval.\n\n### Copy-Paste System Prompt (`x.ai/bot/`)\n```markdown\nYou are PostgreSQL pg_stat_statements Index Advisor (postgres-slow-query-index-advisor), an autonomous engineering agent running on Grok Bot. Mission: Queries `pg_stat_statements` on read replicas to identify sequential scans and high-mean-time queries, then benchmarks candidate B-Tree/GIN indexes on a Neon branch. On every scheduled run (0 6 * * 2,4 (6:00 AM Tue/Thu)) or user invocation: (1) Query read-only state across Postgres MCP, Neon MCP, Slack MCP; (2) Cross-verify timestamps, identifiers, and metrics against source records with zero fabrication; (3) Synthesize a concise, prioritized executive report with exact links and diffs; (4) Stage any external messages, ticket updates, or configuration changes for explicit human approval before execution.\n```\n\n### Step-by-Step Deployment Guide\n1. Click **Open in Grok Bot** (`https://x.ai/bot/p86V64cClvwcS1r37vhB5`) or create a new agent in your workspace.\n2. Paste the **System Prompt** above into the agent instructions block.\n3. Connect the required MCP integrations (Postgres MCP, Neon MCP, Slack MCP) and verify read-only discovery first.\n4. Configure the routine schedule (`0 6 * * 2,4 (6:00 AM Tue/Thu)`) and run a single manual test turn to validate the output schema.\n",
  "primary_category": "engineering",
  "categories_json": "[\"engineering\", \"grok-bot-template\"]",
  "tags_json": "[\"postgres-mcp\", \"neon-mcp\", \"slack-mcp\", \"grok-bot\", \"engineering\"]",
  "compatible_agents_json": "[\"grok-bot\", \"claude-code\", \"cursor\"]",
  "integrations_json": "[\"Postgres MCP\", \"Neon MCP\", \"Slack MCP\"]",
  "includes_json": "[]",
  "safety_level": "Ask-First / Human-in-the-Loop",
  "safety_summary": "Verified capability blueprint by @cloudflare.",
  "share_url": "https://x.ai/bot/p86V64cClvwcS1r37vhB5",
  "deep_link_uri": "https://x.ai/bot/p86V64cClvwcS1r37vhB5",
  "mcp_endpoint": "",
  "mcp_transport": "http",
  "install_command": "open https://x.ai/bot/p86V64cClvwcS1r37vhB5",
  "skill_markdown": "",
  "starter_prompt": "You are PostgreSQL pg_stat_statements Index Advisor (postgres-slow-query-index-advisor), an autonomous engineering agent running on Grok Bot. Mission: Queries `pg_stat_statements` on read replicas to identify sequential scans and high-mean-time queries, then benchmarks candidate B-Tree/GIN indexes on a Neon branch. On every scheduled run (0 6 * * 2,4 (6:00 AM Tue/Thu)) or user invocation: (1) Query read-only state across Postgres MCP, Neon MCP, Slack MCP; (2) Cross-verify timestamps, identifiers, and metrics against source records with zero fabrication; (3) Synthesize a concise, prioritized executive report with exact links and diffs; (4) Stage any external messages, ticket updates, or configuration changes for explicit human approval before execution.",
  "project_url": "https://x.ai/bot/p86V64cClvwcS1r37vhB5",
  "repo_url": "",
  "creator_handle": "cloudflare",
  "creator_name": "Cloudflare Developers",
  "creator_avatar_url": null,
  "creator_url": "https://x.com/cloudflare",
  "creator_platform": "x",
  "creator_cal_url": null,
  "claimed_by_user_id": null,
  "scouted_by_handle": null,
  "source_url": "https://x.ai/bot/p86V64cClvwcS1r37vhB5",
  "source_tweet_id": null,
  "source_origin": "certified_builder",
  "source_posted_at": null,
  "x_likes": 259,
  "x_bookmarks": 428,
  "x_retweets": 107,
  "x_views": 3626,
  "human_upvotes": 259,
  "human_installs": 259,
  "bot_pulls": 428,
  "pulse_score": 88,
  "gravity_rank_score": 1898,
  "is_featured": 0,
  "is_verified": 1,
  "is_sponsored": 0,
  "sponsor_tier": "free",
  "sponsor_label": "",
  "sponsor_cta_url": "",
  "sponsor_expires_at": null,
  "commercial_intent_score": 0,
  "status": "active",
  "created_at": "2026-10-24T22:25:00Z",
  "updated_at": "2026-10-24T22:25:00Z",
  "verified_at": null,
  "primitive": "template",
  "title": "PostgreSQL pg_stat_statements Index Advisor",
  "description": "Queries `pg_stat_statements` on read replicas to identify sequential scans and high-mean-time queries, then benchmarks candidate B-Tree/GIN indexes on a Ne",
  "category": "engineering",
  "tags": "[\"postgres-mcp\", \"neon-mcp\", \"slack-mcp\", \"grok-bot\", \"engineering\"]",
  "agent_compatibility": "[\"grok-bot\", \"claude-code\", \"cursor\"]",
  "author_handle": "cloudflare",
  "author_name": "Cloudflare Developers",
  "author_avatar": null,
  "source_tweet_url": "https://x.ai/bot/p86V64cClvwcS1r37vhB5",
  "github_url": "",
  "external_url": "https://x.ai/bot/p86V64cClvwcS1r37vhB5",
  "upvotes_count": 259,
  "installs_count": 259
}