Skip to content

Conversation

@jackschultz
Copy link
Owner

Summary

  • Add pgcrate queries command for top queries from pg_stat_statements
  • Add pgcrate connections command for connection usage analysis

Completes the "why is prod slow?" workflow:

pgcrate locks → pgcrate queries → pgcrate triage --include-fixes

New Commands

pgcrate queries

  • Sort by total time (default), mean time, or call count
  • Shows cache hit ratio per query
  • Graceful degradation when pg_stat_statements unavailable
  • Status thresholds: Critical (>5s), Warning (>1s)

pgcrate connections

  • Usage vs max_connections with percentage
  • Breakdown by state, user, database
  • Status thresholds: Critical (>90%), Warning (>75%)

Test plan

  • Unit tests for status thresholds, formatting, parsing (390 passing)
  • Integration tests for both commands (137 passing)
  • Capability detection works correctly
  • JSON output matches schema patterns
  • Human output is readable

Add `pgcrate queries` and `pgcrate connections` commands to complete
the "why is prod slow?" workflow.

New commands:
- `queries`: Top queries from pg_stat_statements with sort options
  (total time, mean time, calls) and cache hit ratio
- `connections`: Connection usage vs max_connections with breakdown
  by state, user, and database

Both commands follow established diagnostic patterns with JSON output,
status thresholds, and capability detection.
@jackschultz
Copy link
Owner Author

Superseded by PR #8 and subsequent refactoring. The queries/connections commands are already on main with the new dba namespace.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants