From: Mike Bayer Date: Mon, 1 Jun 2020 20:26:41 +0000 (-0400) Subject: Add a test / comment about test_orm_query X-Git-Tag: rel_1_4_0b1~286 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b05c8a0ef8b6e7bfd169a21e7c1f834fdb00da19;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git Add a test / comment about test_orm_query Change-Id: I8d78b3e75127141da177f711fd91216391a3c859 --- diff --git a/examples/performance/short_selects.py b/examples/performance/short_selects.py index 2f2b19c17d..64d9b05516 100644 --- a/examples/performance/short_selects.py +++ b/examples/performance/short_selects.py @@ -75,6 +75,25 @@ def test_orm_query(n): session.query(Customer).filter(Customer.id == id_).one() +@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."""