RE: [PHP] MySQL performance question
| From: | Maxim Maletsky | Date: | Sun, 04 Aug 2002 21:09:55 +0000 |
| Subject: | RE: [PHP] MySQL performance question | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-111095@lists.php.net to get a copy of this message | ||
I think, these are identical, because, id column is a primary key and
primary keys are unique (and indexed as such).
Sincerely,
Maxim Maletsky
PHP Beginner
www.phpbeginner.com
> -----Original Message-----
> From: Lars Olsson [mailto:lasso@lassoweb.nu]
> Sent: Sunday, August 04, 2002 10:28 PM
> To: php-general@lists.php.net
> Subject: [PHP] MySQL performance question
>
> 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)
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php