blssm
blssm

Reputation: 1

Google Cloud Datastore: does the column order matter in an index?

Does the index order matter when adding an index to Google Cloud Datastore?

For example, this is the case when building an index for other databases. Lets say this is the index on an address table with columns:

Address City State

Any query using the address column can utilize the index, but if the query only has either city and/or state references - the index can not be used. This is because the leftmost column isn't referenced.

Would this also be true for Google Cloud Datastore? Have you found any documentation specifying this?

Upvotes: 0

Views: 558

Answers (1)

Tony P.
Tony P.

Reputation: 191

Yes, the order in which the properties are specified in the index configuration is important. This line can be found in the documentation.

The rows of an index table are sorted first by ancestor and then by property values, in the order specified in the index definition.

The description of the perfect index also goes into some detail about how the scanning of the index table works.

Upvotes: 1

Related Questions