Google数据存储区python每页返回的实体数更少 [英] Google Datastore python returning less number of entities per page
问题描述
我正在使用适用于数据存储区(google-cloud-datastore)版本1.4.0的Python客户端SDK.我正在尝试运行仅键查询:
I am using Python client SDK for Datastore (google-cloud-datastore) version 1.4.0. I am trying to run a key-only query fetch:
query = client.query(kind = 'SomeEntity')
query.keys_only()
查询过滤器在field1上具有EQUAL条件,在field2上具有GREATER_THAN_OR_EQUAL条件.根据field2进行排序
Query filter has EQUAL condition on field1 and GREATER_THAN_OR_EQUAL condition on field2. Ordering is done based on field2
对于提取,我要指定一个限制:
For fetch, I am specifying a limit:
query_iter = query.fetch(start_cursor=cursor, limit=100)
page = next(query_iter.pages)
keyList = [entity.key for entity in page]
nextCursor = query_iter.next_page_token
尽管大约有50个实体满足此查询,但每次获取都会返回大约10-15个结果和一个游标.我可以使用光标来获取所有结果;但这会导致额外的通话开销
Though there are around 50 entities satisfying this query, each fetch returns around 10-15 results and a cursor. I can use the cursor to get all the results; but this results in additional call overhead
这是预期的行为吗?
推荐答案
keys_only查询在单个调用中限制为1000个条目.此操作算作单个实体读取.
keys_only query is limited to 1000 entries in a single call. This operation counts as a single entity read.
对于其他数据存储区的限制,请参阅详细表文档.
但是,在代码中,您确实将游标指定为后续检索操作的起点.可以限制查询,没有光标:
However, in the code, you did specify cursor as a starting point for a subsequent retrieval operation. Query can be limited, without cursor:
query = client.query()
query.keys_only()
tasks = list(query.fetch(limit=100))
query = client.query()
query.keys_only()
tasks = list(query.fetch(limit=100))
有关如何使用限制和游标的详细说明,请请参阅Google Gloud数据存储区的文档
For detailed instruction how to use limits and cursors, please refer documentation of the Google Gloud Datastore
这篇关于Google数据存储区python每页返回的实体数更少的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!