Files
openproject/lib/api
Jan Sandbrink 599d94242d Do not issue SQL count for number of elements on current page
We will be rendering the elements on the current page anyways,
so it's unavoidable that we load them. By forcing us through to_a.size,
we make sure that the elements are loaded first and then only count how
many elements have been loaded. Since AR caches the result, the relation
will not be loaded twice.

Previously we had a useless SQL count query, which can be tremendously
slower than the actual loading of elements. In the case of time entries
for a larger database, the COUNT took ~1.5 seconds, when the loading
of those same elements only took ~20ms. I don't hope that this ratio
is generalizable to all collection API endpoints, but it's definitely
a nice speed boost.
2025-10-16 16:26:02 +02:00
..
2024-09-09 20:47:31 +02:00