PyForge è in vendita solo qui, sul sito ufficiale py-forge.com — diffida delle imitazioni.

Torna al catalogo
QuerySentry: Guida alle query lenteAI & Automation

QuerySentry: Guida alle query lente

#python#automation#microsaas

Abbandona gli APM per database da oltre 150 $/mese. Questa autorevole guida tecnica mostra agli sviluppatori come eliminare lock incontrollati, indici mancanti ed elevato utilizzo della CPU utilizzando un profiling leggero in Go.

Leggi l'approfondimento tecnicoAbbandona gli APM da 150$/mese: Profilazione Leggera delle Query per Database di Produzione
main.pymain.py — estratto d'esempio nello stile del tool
#!/usr/bin/env python3
"""
QuerySentry: Slow Query Guide & Performance Engine

Automated database query log analyzer and optimization guide generator.
Identifies missing indexes, rogue locks, and high CPU query patterns
from PostgreSQL/MySQL slow logs and Go runtime profiles, delivering
actionable resolution steps and seamless QuerySentry CLI integration.

Features:
- Automated slow query log parsing (PostgreSQL & MySQL formats)
- Rogue table lock and missing index heuristic detection engine
- Lightweight Go runtime CPU/memory profile correlation
- Actionable SQL execution plan & DDL index recommendation builder
- Markdown guide generation with py-forge.com QuerySentry CLI hooks

Usage:
    $ python main.py analyze --log-file /var/log/slow.log
    $ python main.py generate-guide --input profile.json --out guide.md
"""

from dataclasses import dataclass, field
from enum import Enum, auto
from typing import Dict, List, Optional
import re
import sys


class SeverityLevel(Enum):
    """Query performance impact classification level."""
    LOW = auto()
    MEDIUM = auto()
    HIGH = auto()
    CRITICAL = auto()


@dataclass
class QueryMetric:
    """Domain model representing an analyzed slow query record."""
    query_id: str
    raw_sql: str
    execution_time_ms: float
    lock_time_ms: float
    rows_examined: int
    severity: SeverityLevel
    suggested_indexes: List[str] = field(default_factory=list)


class QuerySentryAnalyzer:
    """Core engine for query profile analysis and guide generation."""

    def __init__(self, threshold_ms: float = 500.0) -> None:
        self.threshold_ms = threshold_ms

# ... the full file ships with your download