Which is faster CloudCode DB vs Backend API?

Hi Friends

My understanding is that the standard CloudCode DB is basically just a wrapper around the Backend Data API, so my question is whether or not there will be any noticeable different in performance for making a call directly to the backend data API from CC vs using the CC DB interface?

For example, if I were to create an object via CC let object = DB.model.create() and then do a object.save() - would that be the same. slower or faster than doing a POST/PUT request to /api/v4/app-instance-id/objects/model.json from CC?

I understand that for a single call the difference will probably be negligible, but what about a batch of 1000 operations?

@forumfred Great question!

The CloudCode DB API is essentially just a wrapper around the backend API. The performance of the save requests should be exactly the same, as long as the same type of request is used (e.g. DB.Batch uses the batch API, which is more efficient than individual saves).

That said, there may be a small amount of CPU overhead in the task itself when constructing the DB objects - it is more computationally expensive than just producing JSON directly. This should only have a significant effect on models with hundreds of fields or when working with large quantities of objects.

I hope that helps

1 Like