summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2018-11-02 16:40:59 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2018-11-02 16:40:59 -0400
commit88bfa1b89c5b3b2290fa266c53322f003833af40 (patch)
tree1d9b0324f30c258203166303a4cac98f3da8deb3 /lib
parentbc7c212370621a26629392cf247492c773fa63fd (diff)
downloadsqlalchemy-88bfa1b89c5b3b2290fa266c53322f003833af40.tar.gz
Deannotate ORM columns in ColumnEntity
Fixed a minor performance issue which could in some cases add unnecessary overhead to result fetching, involving the use of ORM columns and entities that include those same columns at the same time within a query. The issue has to do with hash / eq overhead when referring to the column in different ways. Fixes: #4347 Change-Id: I191d4d1b1623898060a9accdfd186de16f89a6b7
Diffstat (limited to 'lib')
-rw-r--r--lib/sqlalchemy/orm/query.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/sqlalchemy/orm/query.py b/lib/sqlalchemy/orm/query.py
index bfddb5cfe..cace2e54a 100644
--- a/lib/sqlalchemy/orm/query.py
+++ b/lib/sqlalchemy/orm/query.py
@@ -4243,6 +4243,11 @@ class _ColumnEntity(_QueryEntity):
else:
column = query._adapt_clause(self.column, False, True)
+ if column._annotations:
+ # annotated columns perform more slowly in compiler and
+ # result due to the __eq__() method, so use deannotated
+ column = column._deannotate()
+
if context.adapter:
column = context.adapter.columns[column]
@@ -4251,6 +4256,12 @@ class _ColumnEntity(_QueryEntity):
def setup_context(self, query, context):
column = query._adapt_clause(self.column, False, True)
+
+ if column._annotations:
+ # annotated columns perform more slowly in compiler and
+ # result due to the __eq__() method, so use deannotated
+ column = column._deannotate()
+
context.froms += tuple(self.froms)
context.primary_columns.append(column)