uranusjr commented on code in PR #32630:
URL: https://github.com/apache/airflow/pull/32630#discussion_r1267352895


##########
airflow/utils/db.py:
##########
@@ -1872,3 +1873,11 @@ def get_sqla_model_classes():
         return [mapper.class_ for mapper in Base.registry.mappers]
     except AttributeError:
         return Base._decl_class_registry.values()
+
+
+def get_query_count(query_stmt: Select, session: Session) -> int:
+    """Get count of query."""
+    # Remove ORDER BY clause from the subquery statement since it's 
unnecessary for count
+    # in order to improve the query performance.

Review Comment:
   ```suggestion
       """Get count of query.
   
       A SELECT COUNT() FROM is issued against the subquery built from the
       given statement. The ORDER BY clause is stripped from the statement
       since it's unnecessary for COUNT, and can impact query planning and
       degrade performance.
   
       :meta private:
       """
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to