while looking @
MDL-50919, it was detected that tablelib blindly creates a table with $perpage rows, no matter the total is smaller or any other consideration.
So if you call to pagesize(50000, 1, it still creates a table with 49999 hidden rows.
As a temporal fix, in the linked issue I've applied a quick fix in the caller, only for master:
As references, looking in the tracker about information justifying current/weird behavior, I've found
MDL-41534, but not much else.
So this is about to consider if we could always "optimize" the number of rows created within tablelib or that's not possible (for some unknown reason) and it's a caller responsibility to adjust it.
Also, note that this behavior is 100% reproducible in 28 and 29 manage tags page... and in any other page using tablelib and having a big "SHOW_ALL_PAGE_SIZE" (or similar) defined.