The data browser is built for Chrome, Firefox, Safari, and IE9 and above. Please upgrade your browser, or download Google Chrome to get the best experience.
Back to Questions

Support for Batch and Get

0 votes     2 answers     936 views     


I just tried to perform a GET request in a Batch and was told (well, the API responded ;) that it was not allowed. Is there a reason for this? I'm trying to get aggregate data for my content. So I want to do a get where I pass count:1 and limit:0. I need to sum up the count for 3 types of data. Obviously I could do 3 HTTP calls, but one batch could would be better I think.

Have you considered doing something with Cloud Code do achieve this?

- John Psuik about 1 year ago

I'm sure that would work. But I'm more curious as to why you can't batch/get in the first place.

- Raymond Camden about 1 year ago

2 Answers


I'm not quite sure I get the issue. Isn't a batch GET just a query? The batch API only supports POST because that's how we create/update several objects at once.

Here is a specific example. Using a query, I can ask Parse to return the count of items in a table where property X = 1. Now imagine I want to do this for X=2 and X=3 (my column X can only have 3 values). I'm doing this so I can build a report. If I could do a batch GET, I would. But because I can't do that, I have to run 3 separate GETs. Make sense? Here is a blog post where I discuss it:

- Raymond Camden about 1 year ago

Could you do this in a cloud function? In general gets are slow so we don't like to batch them up. If we did, many users would hit the 30 second timeout we have on requests to Parse.

- Shyam about 1 year ago

Yes, I suppose so. What if BATCH allowed GETs where the limit was always 0? :)

- Raymond Camden about 1 year ago

Counts are fairly slow, so count queries are more likely to take longer than regular queries with limits.

- Shyam about 1 year ago

Fair enough. I'd definitely cache this server-side if I used it in production.

- Raymond Camden about 1 year ago

"Counts are fairly slow, so count queries are more likely to take longer than regular queries with limits."

That may be, but does this ignore the user's data limits? That is, if I'm on a device on a cell connection, I'd rather answer the batched 3 count GETs than pulling all of the data 3 times.

"Could you do this in a cloud function"

For counts this seems like a lot of overhead for something that could simply use existing dynamically composable interfaces.

Unless you're worried about header transmissions, there shouldn't really be any difference in the data transmitted between one command and three commands. You'll also have better incremental results since you can actually display data as it's calculated rather than a batch which must wait on the slowest result (our batch API is currently designed around POST which has order constraints). In CloudCode you'd be able to run the three requests in parallel. Just as importantly you can store results in a cache object which will help reduce latency since counts on non-trivial queries require the query to be executed and all the results to be counted.

- Thomas Bouldin 4 days ago