mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Improved performance of Count Hql queries (#7501)
This commit is contained in:
committed by
Sébastien Ros
parent
406016d12c
commit
020cb8b8bf
@@ -208,7 +208,6 @@ namespace Orchard.ContentManagement {
|
|||||||
public int Count() {
|
public int Count() {
|
||||||
ApplyHqlVersionOptionsRestrictions(_versionOptions);
|
ApplyHqlVersionOptionsRestrictions(_versionOptions);
|
||||||
var hql = ToHql(true);
|
var hql = ToHql(true);
|
||||||
hql = "select count(Id) from Orchard.ContentManagement.Records.ContentItemVersionRecord where Id in ( " + hql + " )";
|
|
||||||
return Convert.ToInt32(_session.CreateQuery(hql)
|
return Convert.ToInt32(_session.CreateQuery(hql)
|
||||||
.SetCacheable(true)
|
.SetCacheable(true)
|
||||||
.UniqueResult())
|
.UniqueResult())
|
||||||
@@ -219,7 +218,7 @@ namespace Orchard.ContentManagement {
|
|||||||
var sb = new StringBuilder();
|
var sb = new StringBuilder();
|
||||||
|
|
||||||
if (count) {
|
if (count) {
|
||||||
sb.Append("select distinct civ.Id as Id").AppendLine();
|
sb.Append("select count(distinct civ.Id)").AppendLine();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sb.Append("select distinct civ.Id as Id");
|
sb.Append("select distinct civ.Id as Id");
|
||||||
|
|||||||
Reference in New Issue
Block a user