Hey Manuel. I made some test with cloud codes with query inside. Here is an example code:
Parse.Cloud.define("codeWithQuery", async (request) => {
const Follow = Parse.Object.extend("Follow");
const getFollow = new Parse.Query(Follow);
return await getFollow.find({useMasterKey:true});
});
This is a simple query. In my follow class I have only 35 objects. I did the test. But performance is decreasing with query.
It started 800 req/sec. But decreased to 300 and I stopped the test. But when I do test on the other cloud code(no query) Parse server still keeps performance and performance doesnt decrease.
Then I changed query method. I was using find method. I changed that to count and made a test.
When I do test with count query, Parse server keeps the performance and doesnt decrease performance. After seeing that I put limit on find query. Its limited to 1. With this way I wanted to know What is the reason for performance loss, Parse Objects(because count query returns number and I tought maybe parse server having dificulties on parse objects) or Big object size we return(since find method with no limit returns all 35 objects and bigger object size).
After putting limit (1), Parse server didnt decrease performance. Returning smaller object size works fine, But when returning object size is bigger, performace decreases.
Edit: This is not correct. It turns out I forgot to change count method to find. Thats why it didnt decreased performance. But when I changed query method to find Performance decrease
To confirm this, I made test against classes endpoint. Instead of testing /functions/myCloudCode I made a test against /classes/Follow
Performance didnt decrease. Parse server send all 35 objects without problem. Parse server had a stable performance. So Its not about sending big objects. After this test I decided to do same query on cloud code without limits. But I will send simple text after that to see if problem happens during query or sending objects. Here is a simple code:
Parse.Cloud.define("helloCodeGetFollow", async (request) => {
const Follow = Parse.Object.extend("Follow");
const getFollow = new Parse.Query(Follow);
var list = await getFollow.find({useMasterKey:true});
return "hello";
});
And performance decreases. If you ask me, I would say problem is: Cloud code cant handle queries which return multiple parse objects.
Edit: Cloud code cant handle parse objects doesnt matter if multiple or singular.
There is something wrong with the cloud code when we do queries. And since count query dont have problem, I think problem happens when parse server convert mongo object to parse object. But thi is hust my guess.
Edit2: After doing test with correct method an seeing query that returns parse object decrease performance, I think problem happens with parse objetcs only. If query returns parse object, performace decreases. If problem is converting mongo object to parse object like I said previously, Then /classes/Follow endpoint also should decrease performace but It doesnt. So I think problem happens when parse server send query result to cloud code. Connection between query and cloud code is broken I guess(Only when returning parse objects).
And I dont know How to find real problem after here. What do you think?
And if you want to I can share test logs with you.