Unnecessary Params on RestWrite.handleInstallation

Hi, guys

We noticed that handleInstallation function from RestWriter file build a slow $or query with params like objectId, deviceToken and installationId. However, why deviceToken and installationId are used for this query when the objectId has already been used?

"find": "_Installation",
"filter": {
"$or": [
{
"_id": "xxxxx"
},
{
"installationId": "16577d08-776b-4822-bde9-xxxxx"
},
{
"deviceToken": "xxxxxxxx..."
}
]
},
"sort": {},
"projection": {},
"returnKey": false,
"showRecordId": false.........
}

There are some verifications that are done with this data: parse-server/RestWrite.js at master · parse-community/parse-server · GitHub

At a first glance, they look necessary for me, but, if you have a different idea, feel free to open an issue at GitHub repo.

Anyways, if you create an index with installationId and another one with deviceToken, this query shouldn’t be a problem for you. These indexes are also necessary for other queries that Parse performs. Maybe we could even create them by default.

1 Like

Thank you for the informations!