You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
对于数据的软删除,Lin CMS是通过delete_time字段是否为null来判断的。因此所有的查询语句,都会拼接上一个 where 条件delete_time is null。这种做法会引发很诸多性能问题:
因为delete_time默认值为null,可以为 null ,会导致查询效率大打折扣,explain会走全表扫描:
对于数据的软删除,
Lin CMS
是通过delete_time
字段是否为null
来判断的。因此所有的查询语句,都会拼接上一个 where 条件delete_time is null
。这种做法会引发很诸多性能问题:因为
delete_time
默认值为null
,可以为 null ,会导致查询效率大打折扣,explain
会走全表扫描:推荐增加
is_deleted
字段来做删除标识,这种是比较常用的逻辑删除做法,查询性能上至少比现在的做法要好:参考链接:
性能优化案例分析之一:软删除是慢查询的罪魁祸首?
小心 MySQL Soft Delete
为什么 MySQL 不推荐默认值为 null ?
The text was updated successfully, but these errors were encountered: