0

On every paged query, I see 2 query one is query with limit and offset. One is count.

Does this have any performance issues on every request when there are multiple joins?

1 Answers1

1

JOINs may or may not be a problem. It depends on whether the JOIN must be completed before doing the pagination.

If the Optimizer cannot get to the OFFSET and LIMIT soon enough, it will have to generate all the possible rows, sort them, skip over OFFSET rows, then finally deliver LIMIT rows.

If the Optimizer can do better, then the first page is fast; the second page is twice as slow; etc. Each page is slower and slower because of having to step over all the previous pages.

That is, OFFSET is the real problem. It is better to "remember where you left off".

More discussion (aimed at MySQL; it may be awkward to map the fix to your framework layer): http://mysql.rjweb.org/doc.php/pagination

Rick James
  • 135,179
  • 13
  • 127
  • 222