子查询的执行计划:
explain SELECT
*
FROM
PLC_CAR plccareo0_
WHERE
(
plccareo0_.topId IN (
SELECT
plcmaineo1_.topId
FROM
PLC_MAIN plcmaineo1_
WHERE
1 = 1
AND plcmaineo1_.lstVerFlag = ‘1’
AND plcmaineo1_.lstEffVerFlag = ‘1’
AND (
plcmaineo1_.businessType IN ( ‘66’, ‘68’ ))
AND plcmaineo1_.coinsLinkCode <> ‘4’
AND (
plcmaineo1_.productCode IN ( ‘0507’ ))
AND topid <> ‘20482241691808’
))
AND plccareo0_.licensePlateNo = ‘续A8B30C’
AND plccareo0_.licenseType = ‘02’
ORDER BY
plccareo0_.startTime DESC;
plccareo0_ 表走了licenseplateno的索引,里面的子查询查询出来的数据为0,为什么plccareo0_这张表不走topId的索引,这样执行返回0条数据,但是plccareo0_表却走了licenseplateno的索引,符合 plccareo0_.licensePlateNo = ‘续A8B30C’ 的数据量1003,当加了hint 强制plccareo0_走topId 的索引的时候,执行计划显示的是索引全表扫