Google Datastore python returning less number of entities per page

♀尐吖头ヾ 提交于 2019-12-10 20:40:33

问题


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()

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

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

Is this behavior expected?


回答1:


keys_only query is limited to 1000 entries in a single call. This operation counts as a single entity read.

For another limitations of Datastore, please refer detailed table in the documentation.

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))

For detailed instruction how to use limits and cursors, please refer documentation of the Google Gloud Datastore




来源:https://stackoverflow.com/questions/53589424/google-datastore-python-returning-less-number-of-entities-per-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!