I don't know anything about PostgreSQL, but I'm a pretty decent SQL Server developer, so I would like to do it anyway :)
How many lines / pages do you expect the user to view each session as much as possible? For example, if you expect the user to show a maximum of 10 pages for each session [each page contains 50 lines], you can make this max and configure the web service so that when the user requests the first page, you cache 10 * 50 lines (or just Id: s for strings, depends on how much memory / concurrent users you have).
This will certainly help speed up your web service to a greater extent than one. And it is quite easy to implement. So:
- When the user requests data from page # 1. Run the request (complete with order, attach checks, etc.), Save all id: s to an array (but not more than 500 identifiers). Returns datarows that matches the id: s in the array at positions 0-9.
- When the user requests page # 2-10. Returns datarows that matches the id: s in the array at positions (page 1) * 50 - (page) * 50-1.
You can also increase the numbers, an array of 500 int: s will only take 2K of memory, but it also depends on how quickly you want to get your initial request / response.
I used a similar technique on a live website, and when the user continued on page 10, I simply switched to queries. I assume that another solution would continue to expand / populate the array. (Starting the request again, but excluding id: s already included).
In any case, I hope this helps!
Fredrik johansson
source share