cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] PranaliM commented on a change in pull request #2260: CLOUDSTACK-10065: Optimize SQL queries in listTemplate API to improve performance
Date Thu, 01 Jan 1970 00:00:00 GMT
PranaliM commented on a change in pull request #2260: CLOUDSTACK-10065: Optimize SQL queries
in listTemplate API to improve performance
URL: https://github.com/apache/cloudstack/pull/2260#discussion_r148003324
 
 

 ##########
 File path: framework/db/src/com/cloud/utils/db/GenericDaoBase.java
 ##########
 @@ -1927,6 +1935,54 @@ public Integer getDistinctCount(SearchCriteria<T> sc) {
         }
     }
 
+    public Integer getDistinctCount(SearchCriteria<T> sc, String[] distinctColumns)
{
+        String clause = sc != null ? sc.getWhereClause() : null;
+        if (clause != null && clause.length() == 0) {
+            clause = null;
+        }
+
+        final StringBuilder str = createDistinctSelect(sc, clause != null, distinctColumns);
+        if (clause != null) {
+            str.append(clause);
+        }
+
+        Collection<JoinBuilder<SearchCriteria<?>>> joins = null;
+        if (sc != null) {
+            joins = sc.getJoins();
+            if (joins != null) {
+                addJoins(str, joins);
+            }
+        }
+
+        final TransactionLegacy txn = TransactionLegacy.currentTxn();
+        final String sql = "SELECT COUNT(*) FROM (" + str.toString() + ") AS tmp";
+
+        PreparedStatement pstmt = null;
+        try {
 
 Review comment:
   Refactored to use try-with-resource

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message