summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2014-09-16 11:57:03 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2014-09-16 11:57:03 -0400
commitb9d430af752b7cc955932a54a8f8db18f46d89a6 (patch)
tree898f400dfe6c475f597167240928338622173e83 /examples
parentd299c40265b747425555d93ad71c1d16ee1b65a4 (diff)
downloadsqlalchemy-b9d430af752b7cc955932a54a8f8db18f46d89a6.tar.gz
- add differentiating examples of list() vs. iteration
Diffstat (limited to 'examples')
-rw-r--r--examples/performance/large_resultsets.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/examples/performance/large_resultsets.py b/examples/performance/large_resultsets.py
index 0a5857b75..fbe77c759 100644
--- a/examples/performance/large_resultsets.py
+++ b/examples/performance/large_resultsets.py
@@ -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