Reputation: 3082
I have an entity king review
as follows properties and value
Review {
merchantId : 'X',
appId : 'Y',
productId : 'Z',
reviewId : '12345',
timeStamp : '1493482784728',
viewtimestamp : '148834892374'
}
and I have defined index as follows
<datastore-index kind="review" ancestor="false" source="manual">
<property name="merchantId" direction="asc"/>
<property name="appId" direction="asc"/>
<property name="productId" direction="asc"/>
<property name="reviewId" direction="asc"/>
<property name="timeStamp" direction="desc"/>
<property name="viewtimestamp" direction="desc"/>
</datastore-index>
And my query is as follows
SELECT reviewId FROM review WHERE merchantId = X AND appId = Y AND productId = Z;
When I execute this query I am getting following index sugession
<datastore-index kind="review" ancestor="false" source="manual">
<property name="appId" direction="asc"/>
<property name="merchantId" direction="asc"/>
<property name="productId" direction="asc"/>
<property name="reviewId" direction="asc"/>
</datastore-index>
Am I missing anything here? How the order get decided? Please help
Upvotes: 2
Views: 136
Reputation: 4692
Indexes don't behave that way. If the system cannot find your precise index for the query, it won't return.
Having a more complex index and trying to serve your query with that index means that the datastore would need to do some calculations instead of a straight up lookup. And datastore doesn't do that.
If you want your queries to go through AT ALL, you need indexes for them, or it just won't run. The ONLY difference is the zigzag merge join algorithm that can help serve your queries if you DON'T have all the indexes. But you can't rely only on it, as it cannot serve everything, it needs partial indexes
Upvotes: 3