pub struct QueryOptimizer {
pub check_select_star: bool,
pub check_missing_limit: bool,
pub check_missing_where: bool,
pub default_limit: usize,
pub join_weight: u32,
pub subquery_weight: u32,
pub where_weight: u32,
}Expand description
SQL 查询优化分析器
基于规则分析 SQL 查询,生成优化建议。 不依赖外部 LLM API,纯规则匹配,适用于离线场景。
Fields§
§check_select_star: bool是否检测 SELECT *
check_missing_limit: bool是否检测缺失的 LIMIT
check_missing_where: bool是否检测缺失的 WHERE
default_limit: usizeLIMIT 建议的默认行数
join_weight: u32复杂度评分中 JOIN 的权重
subquery_weight: u32复杂度评分中子查询的权重
where_weight: u32复杂度评分中 WHERE 条件的权重
Implementations§
Source§impl QueryOptimizer
impl QueryOptimizer
Sourcepub fn with_default_limit(self, limit: usize) -> Self
pub fn with_default_limit(self, limit: usize) -> Self
设置默认 LIMIT 行数
Sourcepub fn disable_select_star_check(self) -> Self
pub fn disable_select_star_check(self) -> Self
禁用 SELECT * 检测
Sourcepub fn disable_missing_limit_check(self) -> Self
pub fn disable_missing_limit_check(self) -> Self
禁用缺失 LIMIT 检测
Sourcepub fn disable_missing_where_check(self) -> Self
pub fn disable_missing_where_check(self) -> Self
禁用缺失 WHERE 检测
Sourcepub fn analyze(&self, sql: &str, schema: &SchemaContext) -> QueryAnalysis
pub fn analyze(&self, sql: &str, schema: &SchemaContext) -> QueryAnalysis
Sourcepub fn format_report(analysis: &QueryAnalysis) -> String
pub fn format_report(analysis: &QueryAnalysis) -> String
生成优化报告文本
Trait Implementations§
Auto Trait Implementations§
impl Freeze for QueryOptimizer
impl RefUnwindSafe for QueryOptimizer
impl Send for QueryOptimizer
impl Sync for QueryOptimizer
impl Unpin for QueryOptimizer
impl UnsafeUnpin for QueryOptimizer
impl UnwindSafe for QueryOptimizer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more