Categories > TinyButStrong general >

Got any solutions for MySQL LIMIT problem?

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Lordo
Date: 2005-01-16
Time: 03:28

Got any solutions for MySQL LIMIT problem?

Did you do anything regarding TBS' problem of loading all the data from MySQL DB and starting to count instead of limiting the result?
What techniques can I use instead?
By: Skrol29
Date: 2005-01-16
Time: 17:33

Re: Got any solutions for MySQL LIMIT problem?

Hi Lordo,

What do you mean by "starting to count instead of limiting the result" ?
By: Lordo
Date: 2005-01-17
Time: 01:54

Re: Got any solutions for MySQL LIMIT problem?

In the manual, it says that when you set a start record number and a limit, TBS does not use "select ... limit ...". Instead, it loads all records and loop over the records you want.
By: Skrol29
Date: 2005-01-17
Time: 03:18

Re: Got any solutions for MySQL LIMIT problem?

TBS hasn't changed its behavior on this point.
And it cannot do better because TBS cannot manage SQL statements. It can only pass them to the Database server.

To understand why, look at the following example.
Imagine the MySQL stored procedure:
CREATE PROCEDURE p_display (OUT asked INT)
BEGIN
  SELECT * FROM t_books WHERE id=asked;
END

With TBS, there is no problem to use the stored procedure:
  $TBS->MergeBlock('blk',$conn,'CALL p_display');
But TBS is simply unable to apply an LIMIT clause on this SQL statement.

This is because the statement doesn't support LIMIT. And they are others MySQL statments that doesn't  support LIMIT neither. And the problem is the same for other Databases types. It would be too complicated to make a SQL analyzis that could apply a LIMIT statement.