我最近更改了所有要使用< =>而不是=,因为我需要检查null.是否有性能方面的顾虑?
解决方法:
没有实际的性能影响,这里是一个可以自己验证的测试
mysql> SELECT BENCHMARK(1000000, (SELECT SQL_NO_CACHE userId FROM Activity WHERE userId<=>42459204 LIMIT 1));
确保您需要使用< =>
NULL-safe equal. This operator
performs an equality comparison like
the = operator, but returns 1 rather
than NULL if both operands are NULL,
and 0 rather than NULL if one operand
is NULL.
如果您只需要检查右值,请执行
col = CONST并且CONST不为空
或t1.col = t2.col