Re: MySQL performance question

From: Date: Mon, 05 Aug 2002 06:10:16 +0000
Subject: Re: MySQL performance question
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-111146@lists.php.net to get a copy of this message
Hi, I think, that the first one is (theoretically) faster, because (IMHO) query is executed from left to right ... Even I don't know how it works internally it seems (to me :) ) clear from syntax rules 1. SELECT data according to WHERE clause 2. apply sorting 3. apply limit HTH Mirek -- Lars Olsson wrote:
Hi all! Sorry for being slightly off topic, but this list seems to have it's fair share of MySQL gurus... :-) Anyway, here's my question: Suppose I create a table (called table1) which has a field with only unique values (called id). Now suppose this table has some rows and that I want to select ONE of them. I usually do this: "SELECT * FROM table1 WHERE id=somevalue" Since id is a unique value this can only return (at most) 1 row. Now let's try this: "SELECT * FROM table1 WHERE id=somevalue LIMIT 1" This query will produce exactly the same result as the first query. But which one (if any) of the two queries are the most efficient? Is it a) The first one, since it's a less complicated SQL query (less time to parse) b) The second one, since it will restrict MySQL from searching further whenever a row is found Any opinions? /lasso (lasso@lassoweb.nu)
-- -- Mirek Novak Anima Publishers CMS development http://www.auto.cz http://www.formule1.cz jabber:mirek@njs.netlab.cz ISEEKYOU:1<one>9<four>9<nine>44<eight> GEsEm:+420603807838

« previous php.general (#111146) next »