2001-05-23 01:40:46 +02:00
|
|
|
#
|
|
|
|
# Testing of found_rows()
|
|
|
|
#
|
|
|
|
|
|
|
|
drop table if exists t1;
|
|
|
|
create table t1 (a int not null auto_increment, b int not null, primary key(a));
|
|
|
|
insert into t1 (b) values (2),(3),(5),(5),(5),(6),(7),(9);
|
|
|
|
select SQL_CALC_FOUND_ROWS * from t1;
|
|
|
|
select found_rows();
|
|
|
|
select SQL_CALC_FOUND_ROWS * from t1 limit 1;
|
|
|
|
select found_rows();
|
2002-03-05 13:22:32 +01:00
|
|
|
select SQL_BUFFER_RESULT SQL_CALC_FOUND_ROWS * from t1 limit 1;
|
|
|
|
select found_rows();
|
2001-05-23 01:40:46 +02:00
|
|
|
select SQL_CALC_FOUND_ROWS * from t1 order by b desc limit 1;
|
|
|
|
select found_rows();
|
|
|
|
select SQL_CALC_FOUND_ROWS distinct b from t1 limit 1;
|
|
|
|
select found_rows();
|
2001-06-25 10:35:22 +02:00
|
|
|
select SQL_CALC_FOUND_ROWS b,count(*) as c from t1 group by b order by c desc limit 1;
|
2001-05-23 01:40:46 +02:00
|
|
|
select found_rows();
|
|
|
|
select SQL_CALC_FOUND_ROWS * from t1 left join t1 as t2 on (t1.b=t2.a) limit 2,1;
|
|
|
|
select found_rows();
|
|
|
|
drop table t1;
|
2002-02-08 02:21:34 +01:00
|
|
|
|
|
|
|
#
|
|
|
|
# Test SQL_CALC_FOUND_ROWS optimization when used with one table and filesort
|
|
|
|
#
|
|
|
|
|
|
|
|
create table t1 (a int not null primary key);
|
|
|
|
insert into t1 values (1),(2),(3),(4),(5);
|
|
|
|
select sql_calc_found_rows a from t1 where a in (1,2,3) order by a desc limit 0,2;
|
|
|
|
select FOUND_ROWS();
|
|
|
|
select sql_calc_found_rows a from t1 where a in (1,2,3) order by a+2 desc limit 0,2;
|
|
|
|
select FOUND_ROWS();
|
|
|
|
drop table t1;
|