Re: [PHP-DB] Smart to use LIMIT 1 when there's only 1 row? From: Doug Semig (dougslist <email protected>)
Date: 11/30/00

If you're selecting the record out by primary key or unique index (SELECT
something FROM somewhere WHERE id = 1029472), then you're just adding
unnecessary complexity for the parser (not much though) and sending a
greater amount of information potentially across the network (if your RDBMS
is not running on the same machine as your Web server/PHP) for no reason.

If you're selecting the record out by a method that would require a full
table or index scan anyway, then it depends upon whether your RDBMS will
complete the full table scan after reaching the LIMIT. Ask around on your
specific RDBMS mailing lists whether the scan continues after reaching the
LIMIT.

Doug

At 07:01 PM 11/30/00 -0500, Noah Spitzer-Williams wrote:
> If you know an sql query is only going to return one row, is it smart
>to add LIMIT 1 to the query anyway? thanks! Noah
> The DevBoard - The Solution to Programmer's Block
> Noah
>Spitzer-Williams
>Founder of the DevBoard
>webmaster <email protected>
>
>http://www.thedevboard.com

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-db-unsubscribe <email protected>
For additional commands, e-mail: php-db-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>