Nij*_*nan 2 python google-app-engine app-engine-ndb
获取NDB查询结果的最佳方法是什么?(少读取操作)
哪一个更有效地获得NDB查询结果计数?普通查询或投影查询?:
EmailSent.query(EmailSent.unsub==True, EmailSent.mail_ref==mail_ref, projection=['to_email']).count()
EmailSent.query(EmailSent.unsub==True, EmailSent.mail_ref==mail_ref).count()
我在这里发现了同样的问题:获取NDB查询长度 - 在Google App Engine上使用Python,但它是用于获取第一个查询结果.
有一个count手术.
https://developers.google.com/appengine/docs/python/ndb/queryclass#Query_count
count(limit=None, **q_options)
返回查询结果的数量,最多可达到限制.这将返回与len(q.fetch(limit))相同的结果,但效率更高.
| 归档时间: |
|
| 查看次数: |
6265 次 |
| 最近记录: |