jsonapi-utils icon indicating copy to clipboard operation
jsonapi-utils copied to clipboard

Reduce the amount of redundant COUNT queries

Open aliaksandrb opened this issue 4 years ago • 0 comments

Hi!

Small proposal for reducing the amount of COUNT queries when the result set is full already. Kinda hits performance.

Currently, the paginator makes COUNT query for each request (unless the :count option provided by user). On some big tables (millions records) with many filters it adds a lot to response time, as while the main result is limited by user defined limit params, like page[:size], the COUNT queries are executed against the whole table.

And it tends to be redundant if the amount of records returned for a query is already less than limit specified (as there won't be any more pages).

aliaksandrb avatar Oct 27 '21 21:10 aliaksandrb