mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-20 00:44:19 +08:00
Optimize the performance of count
This commit is contained in:
parent
82dff2f2fd
commit
a6e33b73de
@ -128,6 +128,15 @@ namespace SqlSugar
|
||||
}
|
||||
return this.Clone().Select<int>(" COUNT(1) ").ToList().FirstOrDefault();
|
||||
}
|
||||
if (this.QueryBuilder.AsTables?.Any() == true)
|
||||
{
|
||||
var tableName = this.QueryBuilder.AsTables.FirstOrDefault().Value;
|
||||
if (tableName.StartsWith(" (SELECT * FROM ("))
|
||||
{
|
||||
var list = this.Clone().Select<int>(" COUNT(1) ").ToList();
|
||||
return list.FirstOrDefault();
|
||||
}
|
||||
}
|
||||
MappingTableList expMapping;
|
||||
int result;
|
||||
_CountBegin(out expMapping, out result);
|
||||
|
@ -157,6 +157,15 @@ namespace SqlSugar
|
||||
var list = await this.Clone().Select<int>(" COUNT(1) ").ToListAsync();
|
||||
return list.FirstOrDefault();
|
||||
}
|
||||
if (this.QueryBuilder.AsTables?.Any() == true)
|
||||
{
|
||||
var tableName= this.QueryBuilder.AsTables.FirstOrDefault().Value;
|
||||
if (tableName.StartsWith(" (SELECT * FROM ("))
|
||||
{
|
||||
var list = await this.Clone().Select<int>(" COUNT(1) ").ToListAsync();
|
||||
return list.FirstOrDefault();
|
||||
}
|
||||
}
|
||||
MappingTableList expMapping;
|
||||
int result;
|
||||
_CountBegin(out expMapping, out result);
|
||||
|
Loading…
Reference in New Issue
Block a user