]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- add differentiating examples of list() vs. iteration
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 16 Sep 2014 15:57:03 +0000 (11:57 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 16 Sep 2014 15:57:03 +0000 (11:57 -0400)
examples/performance/large_resultsets.py

index 0a5857b75bdda51589ac1664879b275d6206fa7a..fbe77c759af31e6c876b48ddcbedd76ee6f7de06 100644 (file)
@@ -52,12 +52,18 @@ def setup_database(dburl, echo, num):
 
 
 @Profiler.profile
-def test_orm_full_objects(n):
-    """Load fully tracked objects using the ORM."""
+def test_orm_full_objects_list(n):
+    """Load fully tracked ORM objects into one big list()."""
+
+    sess = Session(engine)
+    objects = list(sess.query(Customer).limit(n))
+
+
+@Profiler.profile
+def test_orm_full_objects_chunks(n):
+    """Load fully tracked ORM objects a chunk at a time using yield_per()."""
 
     sess = Session(engine)
-    # avoid using all() so that we don't have the overhead of building
-    # a large list of full objects in memory
     for obj in sess.query(Customer).yield_per(1000).limit(n):
         pass