我想在事务中从 AppEngine 数据存储区删除一堆对象:
def F():
items_to_delete = []
for item in db.Query().ancestor(...):
if item.aaa ... item.bbb:
items_to_delete.append(item)
db.delete(items_to_delete)
db.run_in_transaction(F)
是否可以仅获取项目的几个字段(aaa
和 bbb
)?这样的获取会对性能产生积极影响吗?
最佳答案
不可能只获取几个字段;即,您将始终获取整个实体及其所有字段(或仅获取实体键)。来自 App Engine GQL reference docs :
The GQL syntax can be summarized as follows:
SELECT [* | __key__]
[FROM <kind>]]
[WHERE <condition> [AND <condition> ...]]
[ORDER BY <property> [ASC | DESC] [, <property> [ASC | DESC] ...]]
[LIMIT [<offset>,]<count>]
[OFFSET <offset>]
和
A GQL query returns zero or more entities or Keys of the requested kind. Every GQL query always begins with either
SELECT *
orSELECT __key__
. (A GQL query cannot perform a SQL-like "join" query.) Tip:SELECT __key__
queries are faster and cost less CPU thanSELECT *
queries.
关于python - 从 AppEngine 数据存储区删除之前获取部分祖先,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8257470/