mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-07 17:18:24 +08:00
Use limit to improve exists performance
This commit is contained in:
parent
8677b0ed13
commit
4c9c191f62
@ -418,7 +418,7 @@ public interface IService<T> {
|
||||
* @return {@code true} 数据存在,{@code false} 数据不存在。
|
||||
*/
|
||||
default boolean exists(QueryWrapper query) {
|
||||
return SqlUtil.toBool(count(query));
|
||||
return CollectionUtil.isNotEmpty(getMapper().selectListByQuery(query.limit(1)));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -428,7 +428,7 @@ public interface IService<T> {
|
||||
* @return {@code true} 数据存在,{@code false} 数据不存在。
|
||||
*/
|
||||
default boolean exists(QueryCondition condition) {
|
||||
return SqlUtil.toBool(count(condition));
|
||||
return CollectionUtil.isNotEmpty(getMapper().selectListByCondition(condition,1L));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user