数据库:zhcxkj_center_strategy_comprehensive
查询时间:13.8468
执行次数: 22
扫描行数:6263220
发送行数:358356
指纹SQL: SELECT source_sku FROM ? WHERE ( negation_rule_id IN ( ? , ? ) ) ;
真实SQL:SELECT source_sku FROM t_walmart_negation_source_sku_relation WHERE (negation_rule_id IN (55,56));
无人工修改
AISQL修改建议: SQL 优化建议
SELECT source_sku
FROM t_walmart_negation_source_sku_relation
WHERE negation_rule_id IN (55, 56);
优化说明
1. **索引建议**:确保 negation_rule_id 字段上有索引
2. **保持简洁**:原始 SQL 已经很简洁高效
3. **IN 子句优化**:使用 IN 而不是多个 OR 条件
如果 negation_rule_id 已经建立了索引,这个查询的性能应该已经很好。如果没有索引,建议为这个字段添加索引:
CREATE INDEX idx_negation_rule_id ON t_walmart_negation_source_sku_relation(negation_rule_id);
explain表:
| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | SIMPLE | t_walmart_negation_source_sku_relation | None | index | idx_negation_rule_id | idx_source_sku | 410 | None | 5739563 | 11.99 | Using where; Using index |
额外建议:
索引建议:
取出表 【t_walmart_negation_source_sku_relation】 where条件字段 【negation_rule_id】 100000 条记录,重复的数据有:【99998】 条,没有必要为该字段创建索引。
→ 【t_walmart_negation_source_sku_relation】 表,无需添加任何索引。