Improved performance of Count Hql queries (#7501)

This commit is contained in:
Sergio Navarro
2017-01-05 21:34:31 +01:00
committed by Sébastien Ros
parent 406016d12c
commit 020cb8b8bf

View File

@@ -208,7 +208,6 @@ namespace Orchard.ContentManagement {
public int Count() {
ApplyHqlVersionOptionsRestrictions(_versionOptions);
var hql = ToHql(true);
hql = "select count(Id) from Orchard.ContentManagement.Records.ContentItemVersionRecord where Id in ( " + hql + " )";
return Convert.ToInt32(_session.CreateQuery(hql)
.SetCacheable(true)
.UniqueResult())
@@ -219,7 +218,7 @@ namespace Orchard.ContentManagement {
var sb = new StringBuilder();
if (count) {
sb.Append("select distinct civ.Id as Id").AppendLine();
sb.Append("select count(distinct civ.Id)").AppendLine();
}
else {
sb.Append("select distinct civ.Id as Id");