Classify query complexity for optimization decisions
(&self, query: &str)
| 438 | |
| 439 | /// Classify query complexity for optimization decisions |
| 440 | fn classify_query_complexity(&self, query: &str) -> QueryComplexity { |
| 441 | let query_upper = query.to_uppercase(); |
| 442 | |
| 443 | // Count complexity indicators |
| 444 | let mut complexity_score = 0; |
| 445 | |
| 446 | if query_upper.contains("WHERE") { complexity_score += 1; } |
| 447 | if query_upper.contains("ORDER BY") { complexity_score += 1; } |
| 448 | if query_upper.contains("GROUP BY") { complexity_score += 2; } |
| 449 | if query_upper.contains("HAVING") { complexity_score += 2; } |
| 450 | if query_upper.contains("LIMIT") { complexity_score += 1; } |
| 451 | if query_upper.contains("OFFSET") { complexity_score += 1; } |
| 452 | |
| 453 | // Check for aggregate functions |
| 454 | if query_upper.contains("COUNT(") || |
| 455 | query_upper.contains("SUM(") || |
| 456 | query_upper.contains("AVG(") || |
| 457 | query_upper.contains("MAX(") || |
| 458 | query_upper.contains("MIN(") { |
| 459 | complexity_score += 1; |
| 460 | } |
| 461 | |
| 462 | match complexity_score { |
| 463 | 0..=1 => QueryComplexity::Simple, |
| 464 | 2..=4 => QueryComplexity::Medium, |
| 465 | _ => QueryComplexity::Complex, |
| 466 | } |
| 467 | } |
| 468 | |
| 469 | /// Update execution statistics |
| 470 | fn update_execution_stats(&self, _query: &str, execution_time: Duration, success: bool) { |
no outgoing calls
no test coverage detected