Possible Duplicate:
MySQL query with limit and large offset taking forever
My table contains 25,000 rows and im using pagination to display all rows on page. If my page limit is set to 10 rows per page then it displays very fast each page. However if i change the page limit size to 250 rows per page it takes 30 seconds to 1 minute to load the table (display records). The query that im using is this:
SELECT SQL_CALC_FOUND_ROWS Merchants.*, DataSources.DsISOName, PrName
FROM Merchants
INNER JOIN DataSources ON MDsID=DsID
INNER JOIN Processors ON PrID = DsType
ORDER BY MDBA LIMIT 0, 250
This is what i get when i load the page first. Limit numbers 0, 250 get changes if i change the page, so if i visit page 2 Limit will change to :
LIMIT 250, 500
If anyone can see a problem with my query please let me know. I can not understand why does it take 1 minute to load the table when 250 rows are being fetched per page. On mysql table i tried using indexes on various ID's but still same speed.