| Crates.io | dbwarrior |
| lib.rs | dbwarrior |
| version | 0.1.0 |
| created_at | 2025-04-08 08:56:11.842313+00 |
| updated_at | 2025-04-08 08:56:11.842313+00 |
| description | CLI to detect slow and high-row queries in PostgreSQL |
| homepage | https://github.com/sanctusgee/dbwarrior |
| repository | https://github.com/sanctusgee/dbwarrior |
| max_upload_size | |
| id | 1625206 |
| size | 71,263 |
Real-time Postgres query monitoring CLI tool that detects long-running or high-row queries, checks indexing, alerts via Slack/email, logs to file or JSON, and integrates with your workflow.
pg_stat_activityWHERE clause and check if indexes existMakefile for build/run/test/lint/publishcargo install dbwarrior
git clone https://github.com/sanctusgee/dbwarrior.git
cd dbwarrior
make build
Run with:
make run
Create a config.toml in your project root (or pass --config your_file.toml):
db_url = "postgresql://user:password@localhost/yourdb"
query_time_threshold_secs = 30
row_estimate_threshold = 1000000
slack_webhook_url = "https://hooks.slack.com/services/..."
email_fallback = "alerts@yourcompany.com"
log_file_path = "dbwarrior.log"
json_output_path = "dbwarrior.json"
โ ๏ธ Long-running query detected (PID 7483)
Duration: 45s
User: redash
Query:
SELECT * FROM events WHERE user_id IS NOT NULL
Table: events
No index on events(user_id) โ
Suggestion:
โ Add index on events(user_id)
make build # Compile in release mode
make run # Run using config.toml
make test # Run all tests
make lint # Run Clippy linter
make fmt # Format code
make watch # Rebuild on file changes
make publish # Publish to crates.io
Enabled for every push to main and new release tags:
Each alert is written as a line of JSON:
{
"pid": 7483,
"duration_secs": 45,
"user": "redash",
"query": "SELECT * FROM events WHERE user_id IS NOT NULL",
"table": "events",
"column": "user_id",
"index_exists": false,
"suggestion": "Add index on events(user_id)"
}
See CONTRIBUTING.md for setup, linting, and PR guidelines.
MIT ยฉ sanctusgee