diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-06-01 16:26:41 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-06-01 16:26:41 -0400 |
commit | b05c8a0ef8b6e7bfd169a21e7c1f834fdb00da19 (patch) | |
tree | 5f937bc78d13c040f77c812e7962156c6fb8ed46 /examples | |
parent | 03c4166fa852d20b1bc1f4693e70a13725a3ba2e (diff) | |
download | sqlalchemy-b05c8a0ef8b6e7bfd169a21e7c1f834fdb00da19.tar.gz |
Add a test / comment about test_orm_query
Change-Id: I8d78b3e75127141da177f711fd91216391a3c859
Diffstat (limited to 'examples')
-rw-r--r-- | examples/performance/short_selects.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/examples/performance/short_selects.py b/examples/performance/short_selects.py index 2f2b19c17..64d9b0551 100644 --- a/examples/performance/short_selects.py +++ b/examples/performance/short_selects.py @@ -76,6 +76,25 @@ def test_orm_query(n): @Profiler.profile +def test_orm_query_newstyle(n): + """test a straight ORM query of the full entity.""" + + # the newstyle query is faster for the following reasons: + # 1. it uses LABEL_STYLE_DISAMBIGUATE_ONLY, which saves on a huge amount + # of label generation and compilation calls + # 2. it does not use the Query @_assertions decorators. + + # however, both test_orm_query and test_orm_query_newstyle are still + # 25-30% slower than the full blown Query version in 1.3.x and this + # continues to be concerning. + + session = Session(bind=engine) + for id_ in random.sample(ids, n): + stmt = future_select(Customer).where(Customer.id == id_) + session.execute(stmt).scalars().unique().one() + + +@Profiler.profile def test_orm_query_cols_only(n): """test an ORM query of only the entity columns.""" session = Session(bind=engine) |