Re: Smart to use LIMIT 1 when there's only 1 row?

From: Date: Fri, 01 Dec 2000 00:58:25 +0000
Subject: Re: Smart to use LIMIT 1 when there's only 1 row?
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-4911@lists.php.net to get a copy of this message
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@thedevboard.com > >http://www.thedevboard.com

« previous php.db (#4911) next »