Merge pull request #118 from GOODBOY008/main

Use limit to improve exists performance
This commit is contained in:
Michael Yang 2023-08-02 17:05:10 +08:00 committed by GitHub
commit 44c687e098
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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));
}
/**