Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How much data should one JSON call retrieve?

When getting a list of items via a json call is it better to use several small calls (to get info as it's needed) or one large call with all the data.

For example, you have a json call to get a list of books matching a particular title keyword. There are 100 results. You're displaying the data in a paginated form - 10 results per 'page'. Is it more efficient to make one call and get all the results or to make a call for the next 10 on each page?

I would imagine it's partly determined by how many results there are. If it's some huge number the second option seems clear. But what is a good limit to the number you can get in one call - 100, 1000, 10,000 items?

like image 985
9-bits Avatar asked Oct 08 '11 12:10

9-bits


1 Answers

Generally, each ajax call has an overhead and lowering the number of different calls makes the performance better.. unless the data is large...

In paging it is generally better not to fetch all data from the beginning because usually users don't move through all pages.. so you could lower the load on the server by not moving the data .... on another hand, if the data is relatively small or you believe the user will need to see all the data, fetch them to save the overhead of different calls ...

like image 67
AhHatem Avatar answered Oct 11 '22 05:10

AhHatem