Query Insights
The insights endpoint generates actionable recommendations based on query execution patterns, performance anomalies, and optimization opportunities.
Get Insights
GET /v1/analytics/insightscurl "http://query-engine:8080/v1/analytics/insights?days=7" \
-H "Authorization: Bearer $JWT_TOKEN"[
{
"id": "insight-001",
"type": "SLOW_QUERY_PATTERN",
"severity": "WARNING",
"title": "Repeated slow query pattern detected",
"description": "Query pattern 'SELECT * FROM orders JOIN...' has been executed 450 times with average latency of 8.5s",
"recommendation": "Consider creating a materialized view for this join pattern",
"affectedQueries": 450,
"estimatedImpact": "Could reduce average latency to ~200ms",
"createdAt": "2026-02-12T08:00:00Z",
"acknowledged": false
},
{
"id": "insight-002",
"type": "LOW_CACHE_HIT_RATE",
"severity": "INFO",
"title": "Cache hit rate below threshold",
"description": "Cache hit rate is 18% for the 'analytics' schema, below the target of 30%",
"recommendation": "Enable cache warming for frequently-accessed analytics queries",
"estimatedImpact": "Could increase hit rate to ~40% and save 2,000ms avg per query",
"createdAt": "2026-02-12T08:00:00Z",
"acknowledged": false
}
]Insight Types
| Type | Description |
|---|---|
SLOW_QUERY_PATTERN | Repeated execution of slow query patterns |
LOW_CACHE_HIT_RATE | Cache hit rate below target threshold |
HIGH_FAILURE_RATE | Elevated query failure rate |
RESOURCE_BOTTLENECK | CPU, memory, or I/O constraints detected |
QUERY_OPTIMIZATION | Specific query can be optimized |
ENGINE_MISMATCH | Queries routed to suboptimal engine |
QUOTA_WARNING | Approaching query quota limits |
Acknowledge an Insight
Mark an insight as reviewed to remove it from active alerts:
curl -X POST http://query-engine:8080/v1/analytics/insights/insight-001/acknowledge \
-H "Authorization: Bearer $JWT_TOKEN"{
"insightId": "insight-001",
"acknowledged": true,
"acknowledgedAt": "2026-02-12T10:30:00Z"
}