This project is read-only.

Retrieving Data: number of requests needed

May 15, 2012 at 9:18 AM

Both screencasts in the downloads section seem to document a scenario whereby retrieving N records from the service requires N + 1 requests. The first request retrieves a list of URLs which are then used as the basis of subsequent requests to fetch data for individual records.

If my understanding here is correct, this seems like a somewhat inefficient way to retrieve object data - particularly when working with large quantities of data, under heavy load or with low spec hardware.

Is it possible using Restful Objects to retrieve N records with just a single request?

May 15, 2012 at 9:36 AM

Your understanding is correct.

The Restful Objects specification discusses the idea of  minimizing round-trips by the use of an optional ‘x-ro-follow-links’ parameter in any request, with various ways of specifying which links are to be followed.  That would allow, for example, the retrieval of all the details of a list of objects in one go.

This capability is not be included in version 1.0.0 of the Restful Objects spec.  There is, admittedly, nothing to stop us from implementing it in Restful Objects for .NET, as a non-breaking implementation-specific extension, but we are more inclined to wait for it to be formally defined in the Spec.  I suspect that this will be one of the earliest things to be added to the next revision.

While your analysis is correct and there will be situations where the n+1 link-follows will be inefficient  -  for example where you wanted to display the returned list of objects in tabular form -  there are other situations where it is actually more efficient.  My own experience of this comes from the sister project of Naked Objects MVC.  At present, in Naked Objects MVC, the default view of a returned list of objects is a tabular view and this is, indeed, very inefficient  (though the n+1 is all done on the server, not between client and server).  We are going to change that default view to just a list of objects , each displaying its Title (which is also included with each link in Restful Objects) and with a link to the object.  Then have a button to show the table view.  The point is that in many query use cases, the user is returned a list of matches, but can see from the title alone which one or ones they are interested in and can then follow just those links that are of interest.