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:
[email protected]


With regards,
Apache Git Services

Reply via email to