Karthik
Karthik

Reputation: 93

Google Datastore python returning less number of entities per page

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?

Upvotes: 3

Views: 752

Answers (1)

Pawel Czuczwara
Pawel Czuczwara

Reputation: 1520

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


Upvotes: 0

Related Questions