diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-03-30 11:04:24 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-03-30 11:43:00 -0400 |
commit | d3cc4cdcf10db1f50fb2806358532821bc6ed796 (patch) | |
tree | e0b47b4c1df0c4e1907f0c9a02a0aaf4ebb8a7e1 /test/dialect/postgresql/test_compiler.py | |
parent | ffcc16b114f14459f1b90b10e126fc31afef682a (diff) | |
download | sqlalchemy-d3cc4cdcf10db1f50fb2806358532821bc6ed796.tar.gz |
Remove ORDER BY pk from subqueryload, selectinload
Modified the queries used by subqueryload and selectinload to no longer
ORDER BY the primary key of the parent entity; this ordering was there to
allow the rows as they come in to be copied into lists directly with a
minimal level of Python-side collation. However, these ORDER BY clauses
can negatively impact the performance of the query as in many scenarios
these columns are derived from a subquery or are otherwise not actual
primary key columns such that SQL planners cannot make use of indexes. The
Python-side collation uses the native itertools.group_by() to collate the
incoming rows, and has been modified to allow multiple
row-groups-per-parent to be assembled together using list.extend(), which
should still allow for relatively fast Python-side performance. There will
still be an ORDER BY present for a relationship that includes an explicit
order_by parameter, however this is the only ORDER BY that will be added to
the query for both kinds of loading.
Fixes: #5162
Change-Id: I8befd1303c1af7cc24cbf005f39bc01c8b2745f3
Diffstat (limited to 'test/dialect/postgresql/test_compiler.py')
0 files changed, 0 insertions, 0 deletions