View Single Post
  #2 (permalink)  
Old 08-06-2007, 12:22 AM
Gopisoft Gopisoft is offline
D-Web Sr.Programmer
 
Join Date: Feb 2007
Posts: 117
Gopisoft is on a distinguished road
Default Re: MYSQL-Query Performance Tips

Hi,

On a table with 1,00,000 records, Normally we doing this kind of process
Code:
SELECT count(1) FROM mytable WHERE ...   (to get the total count)
SELECT * FROM mytable WHERE ... LIMIT 50
In MySQL advanced to fatch the data, this format is more than 3 time faster than doing.

Code:
SELECT SQL_CALC_FOUND_ROWS * FROM mytable WHERE ... LIMIT 1,50
SELECT FOUND_ROWS();
MySQL to calculate how many rows there would be in the result set, disregarding any LIMIT clause. The number of rows can then be retrieved with SELECT FOUND_ROWS().
Reply With Quote