pdub
pdub

Reputation: 165

Datastore query VERY slow against single indexed property

I have a simple query over a single indexed property and it fairly often takes more than 20 seconds, sometimes as much as 45 seconds. The Kind only has 10k entities and the query is returning about 110. Here is the query:

SELECT * FROM MyKind WHERE MyProperty = 'xyz'

Normally this only takes a few seconds (which still feels too long), but occasionally it takes a REALLY long time as described above.

The entities that are returned are not in an entity group, they are all their own root entity. Would this help if I put them into the same entity group? They are very related to each other, so it would make sense to change the data model this way.

Just wondering if the physical location of the entities is spread out as it is today and putting them into an entity group would keep them together and eliminate a bunch of rpc overhead.

Upvotes: 0

Views: 1117

Answers (1)

Methkal Khalawi
Methkal Khalawi

Reputation: 2477

I invite you to check the best practices with Cloud Datastore. Hotspotting in Cloud Datastore can happen for many reasons:

  • indexing properities with with monotonically increasing values (such as a NOW() timestamp).
  • high read or write rates to lexicographically close documents
  • A high rate of reads of non-existent entities can lead to hotspotting

For monitoring and to check for hotspotting I suggest you to use custom metrics in Stackdriver. Here are the available Datastore metrics. if you need more help, ping me.

Upvotes: 2

Related Questions