Re: DB - Query(limit) vs. LimitQuery() in MySQL

From: Date: Tue, 28 Sep 2004 11:32:56 +0000
Subject: Re: DB - Query(limit) vs. LimitQuery() in MySQL
References: 1 2  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-14652@lists.php.net to get a copy of this message
Peter Bowyer wrote:
Does LimitQuery take advantage of MySQLs features when executing the query?
Yes, as does the PostgreSQL driver. Some of the others emulate this.
Does this mean that LimitQuery doesn't extract *all* the records from the table and *then* extracts the necessary ones but rather translates the use of LimitQuery to a MySQL-standard query (SELECT ... LIMIT a,b) hence taking advantage of MySQLs LIMIT option?
Use limitQuery if you care about portability. It's designed for this task. If you want pure speed then using query() and writing the limit SQL will be fractionally faster, but in that case why not forget using PEAR::DB and use the native mysql functions instead?
Of course I'm interested in portability but the costs can also be too big - for instance if the LimitQuery() actually extracted 1.000.000+ records from a table in order to show 10 records to the user it would probably be quite time-consuming - but if LimitQuery() is "intelligent" enough to take advantage of MySQL's LIMIT-syntax then everything is okay! I found the following in the man-pages for the DB-package: (http://pear.php.net/manual/en/package.database.db.db-common.limitquery.php) "Depending on the database you will not really get more speed compared to query(). The advantage of limitQuery() is the deleting of unneeded rows in the resultset, as early as possible. So this can decrease memory usage." - I can't figure out exactly what this means - will the method extract all records from a table and THEN delete the unnecessary ones OR will the method just extract the necessary records - when using MySQL as DBMS? Cheers, Tommy Ipsen

« previous php.pear.general (#14652) next »