How to efficiently count rows in a query by limiting the number or found rows?
First, it's almost never OK to use LIMIT without ORDER BY, because you will not get consistent results across different executions of the query. So, especially for the pagination queries, I'd use:

SELECT &lt;list of columns&gt;
FROM &lt;tables&gt;
WHERE &lt;conditions&gt;
ORDER BY &lt;some columns&gt;
LIMIT rows_per_page
OFFSET x ;


Now, to find the number of pages this query could return - and with the extra condition that you will not use more than 50 pages - I'd try a separate query;

SELECT CEIL( COUNT(*) / 50 ) AS pages
FROM
  ( SELECT NULL
    FROM &lt;tables&gt;
    WHERE &lt;conditions&gt;
    LIMIT 50 * rows_per_page
  ) AS x ;


(and that is an exception to the "never use LIMIT without ORDER BY" rule above :)