I have a question about getting Cursor
Target function: https://godoc.org/google.golang.org/appengine/datastore#Iterator.Cursor
As far as can be read from the following code, offset is set when getting a Cursor https://github.com/golang/appengine/blob/master/datastore/query.go#L702-L705
When I checked the result when this function was executed with the stack trace of GCP console, Insights displays a warning
Issue: Use of offset in datastore queries.
Description: Your app made 1 remote procedure calls to datastore.query () and datastore.next () using offset.
Recommendation: Use cursor instead of offset.
Query Details
g.co/gae/datastore/offset 10
g.co/gae/datastore/skipped 10
offset affects performance and billing, I want to avoid this behavior Is there a way to avoid using offset? Or is this the correct behavior?
From Offsets versus cursors:
Although Cloud Datastore supports integer offsets, you should avoid using them. Instead, use cursors. Using an offset only avoids returning the skipped entities to your application, but these entities are still retrieved internally. The skipped entities do affect the latency of the query, and your application is billed for the read operations required to retrieve them. Using cursors instead of offsets lets you avoid all these costs.
The q.offset
you're referring to is an internal variable used for the Cursor
implementation, it's not the explicit query offset that the above quote mentions.
So you should be fine using Cursor
.