Let say I have two queries to run:
# Q1
Chair.query(ndb.AND(Chair.type == 'A', Chair.invented_at < '2014'))
# Q2
Chair.query(ndb.AND(Chair.type == 'A', Chair.cost == 2, Chair.invented_at < '2014'))
Q1 and Q2 have an inequality filter, therefore those queries require composite indexes.
The index automatically generated by the development server would contain two indexes, one for each query.
# Index for Q1
- kind: Chair
properties:
- name: type
- name: invented_at
# Index for Q2
- kind: Chair
properties:
- name: type
- name: cost
- name: invented_at
But wouldn't it be more efficient in terms of storage and write operations to only use the second Index (Q2) and modify Q1 (it might be possible in some cases) so it uses Q2 index too ? Or is it easier for the datastore to use smaller but more indexes ?
This question is completely hypothetical, I am just wondering how the datastore would react.