Hi guys,
Which of the following is more efficient:
Using Query.count(1) to test, then using .get() if there is a result:
-------
q = MyModel.all().filter("field =", value)
count = q.count(1)
if count:
result = q.get()
do_stuff(result)
else:
create_entity()
--------
Or just calling .get():
-------
result = MyModel.all().filter("field =", value).get()
if result:
do_stuff(result)
else:
create_entity()
-----
The first one saves resources by not fetching the entity unless it has
to, whereas the second one calls .get() no matter what, but doesn't
use .count()
--
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-appengine?hl=en.