I have a requirement where I need to filter by propA and fitlter and sort by propB but never have to do just either propA or propB. I asked to not index propA and propB and created a compound index on both. But that didn't work.
As per App Engine DataStore - Compound Indexes - datastore-indexes - not working
a composite index also requires specifying the component props to be indexed. Does that mean, internally there will be 5 indexes, one for the compound index and 2 each (asc/desc) for the two props? I am trying to understand the storage requirements of a compound index.
Yes, the individual properties propA
and propB
have to be indexed as well.
But no, you don't have to explicitly have to create (asc and desc) indexes for them, just let the datastore automatically create the built-in indexes for them (one per property, not 2) by simply not declaring them "not indexed". From Indexes:
Built-in indexes
By default, a Datastore mode database automatically predefines an index for each property of each entity kind. These single property indexes are suitable for simple types of queries.
So there will be 3 indexes in your case, 2 built-in and 1 composite.