I am making a “simple” query that uses the OR operator and the new inequality operator on multiple fields in firestore, the query is searching over an Id that its repeated on my database with aprox 27k items:
This is an example of the query:
.where('myId', '==', 123)
.where('createdAt', '<=', new Date())
.where(
Filter.or(
Filter.where('deletedAt', '>=', new Date()),
Filter.where('deletedAt', '==', null)
)
)
.orderBy('createdAt', 'desc')
.limit(500)
The problem is that the query just hangs out and never finished, throwing the error 14 UNAVAILABLE: Query timed out. Please try either limiting the entities scanned, or run with an updated index configuration..
What may be happening here?, maybe am missing some weird index?, I tried to run the explain function but with the analyze flag the result is the same, without it, the plan summary its this one:
PlanSummary {
indexesUsed: [
{
properties: '(myId ASC, createdAt DESC, deletedAt DESC, __name__ DESC)',
query_scope: 'Collection'
},
{
properties: '(myId ASC, deletedAt ASC, createdAt DESC, __name__ DESC)',
query_scope: 'Collection'
}
]
}
The first time I executed the query, firestore indicate that some index were missing, I obviosly add them but the thing still happens (its weird because if myId
has a more small subset of data, the query completes without problem).
(I also create a bug report here)