以下是我用于分页的代码。但是,尽管只选择了几条记录,但它访问表格的所有记录所花费的时间也相同。我需要做些什么才能让它更快?
CREATE PROCEDURE `random_procedure`(random params,in page_no int,in per_page int,out total_records int)
BEGIN
set @statement := concat(@statement,'limit ',page_no*per_page-per_page,',',per_page); //@statement is the statement selecting records i need to display
PREPARE stmt FROM @statement;
EXECUTE stmt;
select FOUND_rows() into total_records;
END