什么是只获取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()
我在这里发现了同样的问题:Get NDB query length - using Python on Google App Engine,但它是为了获得第一个查询结果。
有一个
count
操作。https://developers.google.com/appengine/docs/python/ndb/queryclass#Query_count
count(limit=None, **q_options)
使用
count
。如果你能分页,效率上的差别可以忽略不计。相关问题 更多 >
编程相关推荐