diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2022-11-13 21:48:53 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2022-11-15 14:16:06 -0500 |
commit | d5be2cc1391d0ff4b21557b036eba4713fde7bcf (patch) | |
tree | a50189a0e7cf8d8ff7f9d1081246d746347e1951 /test/base/test_utils.py | |
parent | 93dc7ea1502c37793011b094447641361aff5aba (diff) | |
download | sqlalchemy-d5be2cc1391d0ff4b21557b036eba4713fde7bcf.tar.gz |
perf improvements related to corresponding_column (2)
commit two of two. this reorganizes ColumnCollection
to build a new index up front that's used to optimize
the corresponding_column() method.
Additional performance enhancements within ORM-enabled SQL statements,
specifically targeting callcounts within the construction of ORM
statements, using combinations of :func:`_orm.aliased` with
:func:`_sql.union` and similar "compound" constructs, in addition to direct
performance improvements to the ``corresponding_column()`` internal method
that is used heavily by the ORM by constructs like :func:`_orm.aliased` and
similar.
Fixes: #8796
Change-Id: I4a76788007d5a802b9a4081e6a0f6e4b52497b50
Diffstat (limited to 'test/base/test_utils.py')
-rw-r--r-- | test/base/test_utils.py | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/test/base/test_utils.py b/test/base/test_utils.py index 098652928..349ee8c05 100644 --- a/test/base/test_utils.py +++ b/test/base/test_utils.py @@ -567,15 +567,32 @@ class ToListTest(fixtures.TestBase): class ColumnCollectionCommon(testing.AssertsCompiledSQL): def _assert_collection_integrity(self, coll): - eq_(coll._colset, set(c for k, c in coll._collection)) + eq_(coll._colset, set(c for k, c, _ in coll._collection)) d = {} - for k, col in coll._collection: + for k, col, _ in coll._collection: d.setdefault(k, (k, col)) d.update( - {idx: (k, col) for idx, (k, col) in enumerate(coll._collection)} + {idx: (k, col) for idx, (k, col, _) in enumerate(coll._collection)} ) eq_(coll._index, d) + if not coll._proxy_index: + coll._init_proxy_index() + + all_metrics = { + metrics for mm in coll._proxy_index.values() for metrics in mm + } + eq_( + all_metrics, + {m for (_, _, m) in coll._collection}, + ) + + for mm in all_metrics: + for eps_col in mm.get_expanded_proxy_set(): + assert mm in coll._proxy_index[eps_col] + for mm_ in coll._proxy_index[eps_col]: + assert eps_col in mm_.get_expanded_proxy_set() + def test_keys(self): c1, c2, c3 = sql.column("c1"), sql.column("c2"), sql.column("c3") c2.key = "foo" |