重现步骤
反馈人:袁慧斌
数据库: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】 表,无需添加任何索引。


历史记录  
  1. 2025-09-09 09:33:57, 由 李乐同 创建。
  2. 2025-09-09 14:22:42, 由 任芳涛 解决,方案为 历史bug(180天以上) 。
    修改了 解决方案,旧值为 "",新值为 "history"。
    修改了 解决版本,旧值为 "",新值为 "trunk"。
    修改了 解决日期,旧值为 "",新值为 "2025-09-09 14:22:08"。
    修改了 指派给 ,旧值为 "renfangtao",新值为 "liletong"。
    修改了 Bug状态 ,旧值为 "active",新值为 "resolved"。
    修改了 是否确认,旧值为 "0",新值为 "1"。
    修改了 解决者 ,旧值为 "",新值为 "renfangtao"。

  3. 2025-09-09 14:29:13, 由 李乐同 编辑。
    修改了 所属模块 ,旧值为 "0",新值为 "1872"。
    修改了 业务部门 ,旧值为 "0",新值为 "2"。
    修改了 开发责任人,旧值为 "",新值为 "renfangtao"。
    修改了 测试责任人,旧值为 "",新值为 "liuyingying"。
    修改了 解决时效 ,旧值为 "0",新值为 "4.80"。
    修改了 重现步骤 ,区别为:
    001- 反馈人:袁慧斌
    001+ 反馈人:袁慧斌 数据库: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
    002- 数据库:zhcxkj_center_strategy_comprehensive
    002+ select_type
    003- 查询时间:13.8468
    003+ table
    004- 执行次数: 22
    004+ partitions
    005- 扫描行数:6263220
    005+ type
    006- 发送行数:358356
    006+ possible_keys
    007- 指纹SQL: SELECT source_sku FROM ? WHERE ( negation_rule_id IN ( ? , ? ) ) ;
    007+ key
    008- 真实SQL:SELECT source_sku FROM t_walmart_negation_source_sku_relation WHERE (negation_rule_id IN (55,56));
    008+ key_len
    009- 无人工修改
    009+ ref
    010- AISQL修改建议: SQL 优化建议
    010+ rows
    011-
    011+ filtered
    012-
    012+ Extra
    013- SELECT source_sku
    013+ 1
    014- FROM t_walmart_negation_source_sku_relation
    014+ SIMPLE
    015- WHERE negation_rule_id IN (55, 56);
    015+ t_walmart_negation_source_sku_relation
    016-
    016+ None
    017-
    017+ index
    018- 优化说明
    018+ idx_negation_rule_id
    019-
    019+ idx_source_sku
    020- 1. **索引建议**:确保 negation_rule_id 字段上有索引
    020+ 410
    021- 2. **保持简洁**:原始 SQL 已经很简洁高效
    021+ None
    022- 3. **IN 子句优化**:使用 IN 而不是多个 OR 条件
    022+ 5739563
    023-
    023+ 11.99
    024- 如果 negation_rule_id 已经建立了索引,这个查询的性能应该已经很好。如果没有索引,建议为这个字段添加索引:
    024+ Using where; Using index
    025-
    025+
    026-
    026+ 额外建议: 索引建议: 取出表 【t_walmart_negation_source_sku_relation】 where条件字段 【negation_rule_id】 100000 条记录,重复的数据有:【99998】 条,没有必要为该字段创建索引。→ 【t_walmart_negation_source_sku_relation】 表,无需添加任何索引。
    027- CREATE INDEX idx_negation_rule_id ON t_walmart_negation_source_sku_relation(negation_rule_id);
    028- explain表:
    029-
    030-
    031-
    032-
    033-
    034-
    035-
    036-
    037-
    038-
    039- id
    040-
    041-
    042- select_type
    043-
    044-
    045- table
    046-
    047-
    048- partitions
    049-
    050-
    051- type
    052-
    053-
    054- possible_keys
    055-
    056-
    057- key
    058-
    059-
    060- key_len
    061-
    062-
    063- ref
    064-
    065-
    066- rows
    067-
    068-
    069- filtered
    070-
    071-
    072- Extra
    073-
    074-
    075-
    076-
    077-
    078-
    079- 1
    080-
    081-
    082- SIMPLE
    083-
    084-
    085- t_walmart_negation_source_sku_relation
    086-
    087-
    088- None
    089-
    090-
    091- index
    092-
    093-
    094- idx_negation_rule_id
    095-
    096-
    097- idx_source_sku
    098-
    099-
    100- 410
    101-
    102-
    103- None
    104-
    105-
    106- 5739563
    107-
    108-
    109- 11.99
    110-
    111-
    112- Using where; Using index
    113-
    114-
    115-
    116-
    117-
    118- 额外建议:
    119- 索引建议:
    120- 取出表 【t_walmart_negation_source_sku_relation】 where条件字段 【negation_rule_id】 100000 条记录,重复的数据有:【99998】 条,没有必要为该字段创建索引。
    121-
    122- → 【t_walmart_negation_source_sku_relation】 表,无需添加任何索引。
    123-
    124-
    001- 反馈人:袁慧斌<br />
    001+ 反馈人:袁慧斌<br /> 数据库:zhcxkj_center_strategy_comprehensive<br /> 查询时间:13.8468<br /> 执行次数: 22<br /> 扫描行数:6263220<br /> 发送行数:358356<br /> 指纹SQL: SELECT source_sku FROM ? WHERE ( negation_rule_id IN ( ? , ? ) ) ;<br /> 真实SQL:SELECT source_sku FROM t_walmart_negation_source_sku_relation WHERE (negation_rule_id IN (55,56));<br /> 无人工修改<br /> AISQL修改建议: SQL 优化建议<br /><br /><br /> SELECT source_sku<br /> FROM t_walmart_negation_source_sku_relation<br /> WHERE negation_rule_id IN (55, 56);<br /><br /><br /> 优化说明<br /><br /> 1. **索引建议**:确保 negation_rule_id 字段上有索引<br /> 2. **保持简洁**:原始 SQL 已经很简洁高效<br /> 3. **IN 子句优化**:使用 IN 而不是多个 OR 条件<br /><br /> 如果 negation_rule_id 已经建立了索引,这个查询的性能应该已经很好。如果没有索引,建议为这个字段添加索引:<br /><br /><br /> CREATE INDEX idx_negation_rule_id ON t_walmart_negation_source_sku_relation(negation_rule_id);<br /> explain表:<br /><br /><br /><br /><br /><br /><br /><table><tbody><tr><th>id</th>
    002- 数据库:zhcxkj_center_strategy_comprehensive<br />
    002+ <th>select_type</th>
    003- 查询时间:13.8468<br />
    003+ <th>table</th>
    004- 执行次数: 22<br />
    004+ <th>partitions</th>
    005- 扫描行数:6263220<br />
    005+ <th>type</th>
    006- 发送行数:358356<br />
    006+ <th>possible_keys</th>
    007- 指纹SQL: SELECT source_sku FROM ? WHERE ( negation_rule_id IN ( ? , ? ) ) ;<br />
    007+ <th>key</th>
    008- 真实SQL:SELECT source_sku FROM t_walmart_negation_source_sku_relation WHERE (negation_rule_id IN (55,56));<br />
    008+ <th>key_len</th>
    009- 无人工修改<br />
    009+ <th>ref</th>
    010- AISQL修改建议: SQL 优化建议<br />
    010+ <th>rows</th>
    011- <br />
    011+ <th>filtered</th>
    012- <br />
    012+ <th>Extra</th>
    013- SELECT source_sku<br />
    013+ </tr></tbody><tbody><tr><td>1</td>
    014- FROM t_walmart_negation_source_sku_relation<br />
    014+ <td>SIMPLE</td>
    015- WHERE negation_rule_id IN (55, 56);<br />
    015+ <td>t_walmart_negation_source_sku_relation</td>
    016- <br />
    016+ <td>None</td>
    017- <br />
    017+ <td>index</td>
    018- 优化说明<br />
    018+ <td>idx_negation_rule_id</td>
    019- <br />
    019+ <td>idx_source_sku</td>
    020- 1. **索引建议**:确保 negation_rule_id 字段上有索引<br />
    020+ <td>410</td>
    021- 2. **保持简洁**:原始 SQL 已经很简洁高效<br />
    021+ <td>None</td>
    022- 3. **IN 子句优化**:使用 IN 而不是多个 OR 条件<br />
    022+ <td>5739563</td>
    023- <br />
    023+ <td>11.99</td>
    024- 如果 negation_rule_id 已经建立了索引,这个查询的性能应该已经很好。如果没有索引,建议为这个字段添加索引:<br />
    024+ <td>Using where; Using index</td>
    025- <br />
    025+ </tr></tbody></table><br />
    026- <br />
    026+ 额外建议:<br /> 索引建议:<br /> 取出表 【t_walmart_negation_source_sku_relation】 where条件字段 【negation_rule_id】 100000 条记录,重复的数据有:【99998】 条,没有必要为该字段创建索引。<br /><br /><span style="color:#008000;font-weight:bold;">→ 【t_walmart_negation_source_sku_relation】 表,无需添加任何索引。</span><br /><br /><br />
    027- CREATE INDEX idx_negation_rule_id ON t_walmart_negation_source_sku_relation(negation_rule_id);<br />
    028- explain表:<br />
    029- <br />
    030- <br />
    031- <br />
    032- <br />
    033- <br />
    034- <br />
    035- <table>
    036- <tbody>
    037- <tr>
    038- <th>
    039- id
    040- </th>
    041- <th>
    042- select_type
    043- </th>
    044- <th>
    045- table
    046- </th>
    047- <th>
    048- partitions
    049- </th>
    050- <th>
    051- type
    052- </th>
    053- <th>
    054- possible_keys
    055- </th>
    056- <th>
    057- key
    058- </th>
    059- <th>
    060- key_len
    061- </th>
    062- <th>
    063- ref
    064- </th>
    065- <th>
    066- rows
    067- </th>
    068- <th>
    069- filtered
    070- </th>
    071- <th>
    072- Extra
    073- </th>
    074- </tr>
    075- </tbody>
    076- <tbody>
    077- <tr>
    078- <td>
    079- 1
    080- </td>
    081- <td>
    082- SIMPLE
    083- </td>
    084- <td>
    085- t_walmart_negation_source_sku_relation
    086- </td>
    087- <td>
    088- None
    089- </td>
    090- <td>
    091- index
    092- </td>
    093- <td>
    094- idx_negation_rule_id
    095- </td>
    096- <td>
    097- idx_source_sku
    098- </td>
    099- <td>
    100- 410
    101- </td>
    102- <td>
    103- None
    104- </td>
    105- <td>
    106- 5739563
    107- </td>
    108- <td>
    109- 11.99
    110- </td>
    111- <td>
    112- Using where; Using index
    113- </td>
    114- </tr>
    115- </tbody>
    116- </table>
    117- <br />
    118- 额外建议:<br />
    119- 索引建议:<br />
    120- 取出表 【t_walmart_negation_source_sku_relation】 where条件字段 【negation_rule_id】 100000 条记录,重复的数据有:【99998】 条,没有必要为该字段创建索引。<br />
    121- <br />
    122- <span style="color:green;font-weight:bold;">→ 【t_walmart_negation_source_sku_relation】 表,无需添加任何索引。</span><br />
    123- <br />
    124- <br />
  4. 2025-09-09 14:29:16, 由 李乐同 关闭。
    修改了 Bug状态 ,旧值为 "resolved",新值为 "closed"。
    修改了 指派给 ,旧值为 "liletong",新值为 "closed"。
    修改了 由谁关闭,旧值为 "",新值为 "liletong"。
    修改了 关闭日期,旧值为 "",新值为 "2025-09-09 14:29:16"。
所属项目 技术中心-需求池
所属模块 多平台   walmart
所属计划
所属迭代
Bug类型
严重程度 一般
优先级 P2
Bug状态 已关闭
业务部门 总经办
影响功能
开发责任人 任芳涛
测试责任人 刘颖颖
解决时效 4.8
激活次数 0
激活日期
是否确认 是
当前指派 Closed 于 2025-09-09 14:29:16
截止日期 0000-00-00
上线时间 2025-09-09 14:28:00
上线时效 4.9
操作系统
浏览器
关键词
抄送给
所属迭代
相关需求
相关任务
由谁创建 李乐同 于 2025-09-09 09:33:57
影响环境 生产环境-业务反馈
由谁解决 任芳涛 于 2025-09-09 14:22:08
解决版本 主干
解决方案 历史bug(180天以上)
由谁关闭 李乐同 于 2025-09-09 14:29:16
最后修改 李乐同 于 2025-09-09 14:29:16
相关Bug