query_analyzer 1.0.0
query_analyzer: ^1.0.0 copied to clipboard
Ultra Pro Query Analyzer — A professional Dart package for automatic monitoring, profiling, and intelligent diagnosis of slow database queries.
Changelog #
All notable changes to Query Analyzer will be documented in this file.
The format follows Keep a Changelog and this project adheres to Semantic Versioning.
1.0.0 — 2026-06-01 #
Added #
Core
QueryAnalyzerCore— central analysis engine withStreamController<AnalyzedQuery>QueryAnalyzerFacade— top-level convenience API (create,wrap,generateReport,topSlowQueries)QueryAnalyzerConfig/QueryAnalyzerConfig.customwith fullcopyWithandvalidate()
Models
AnalyzedQuery— fully self-contained analysis record with computedimpactScoreParsedQuery— structural breakdown of a SQL statementDetectionResult— aggregated detector output withseverityScoreandmaxSeverityQueryIssue— individual problem withIssueTypeandIssueSeverityQuerySuggestion— concrete actionable fix with factory constructorsPerformanceMetric— Welford's online variance, percentile map, error rateDatabaseSchema/TableSchema/ColumnSchema/IndexSchemaAnalysisReport— aggregated time-boxed performance report
Detectors
FullTableScanDetector— no-WHERE, un-indexed WHERE, leading-wildcard LIKEMissingIndexDetector— WHERE columns, JOIN columns (both sides)NPlusOneDetector— sliding-window fingerprint counterLargeResultDetector— actual row count feedback + structural heuristicsSubqueryDetector— correlated sub-queries, deep nesting, SELECT-list sub-queries
Parser & Utilities
QueryParser— regex-based lightweight SQL parser (type, tables, WHERE, JOIN, LIMIT, depth)ParserUtils—normalize(),maskSensitiveValues(),fingerprint(),extractWhereColumns()PrecisionTimer— high-resolution wall-clock timer withmeasureWithResult()CacheManager<K,V>— TTL-based in-memory cacheQaLogger— configurable console output wrapper overdart:loggingQueryAnalyzerConfig— full configuration with validation
Wrappers
DatabaseWrapper— transparent query/execute interceptorQueryWrapper.measure()— single-call measurement utilityConnectionPoolWrapper— round-robin pool wrapper
Storage
MetricsStorage— in-memory ring-buffer +PerformanceMetricaggregationLocalDatabase— JSON-Lines persistence stub (cross-platform)DailySummary— 24-hour snapshot DTO
Reporting
ReportGenerator— time-windowedAnalysisReportwith percentile computationReportExporter—toJson(),toCsv(),toHtml(),toMarkdown()
Alerts
AlertManager—QueryListenerwith per-channel cooldown enforcementConsoleAlertChannel— stdout pretty-printLoggingAlertChannel— routes toQaLoggerSlackAlertChannel— incoming webhook with rich attachment payloadWebhookAlertChannel— generic HTTP POST with custom headersThresholdConfig— production and development presets
Database Adapters
PostgresAdapter— full schema introspection,EXPLAIN ANALYZEparsingMySqlAdapter—information_schemaintrospection,EXPLAIN FORMAT=JSONSQLiteAdapter—PRAGMA-based introspection,EXPLAIN QUERY PLAN
Exceptions
AnalyzerException(base)ConfigurationExceptionDatabaseIntrospectionExceptionQueryParseExceptionMetricsStorageExceptionAlertDeliveryExceptionReportExportException
Tests
- 4 unit test suites: parser, detectors, analyzer+wrapper, suggestion engine
- 1 end-to-end integration suite with mock database
- Fixture library:
SampleQueries,MockDatabaseConnection,TestSchemas
Examples
basic_usage.dartadvanced_features.dartcustom_alerts.dartreport_generation.dartweb_server_integration.dart
[Unreleased] #
Planned #
- MongoDB adapter
- Prometheus / OpenMetrics export
- Predictive analytics (ML-based)
- Datadog / New Relic integration
- Full SQLite persistence via
sqflite_common_ffi