RE: [PHP] MySQL performance question
| From: | John Holmes | Date: | Mon, 05 Aug 2002 11:09:41 +0000 |
| Subject: | RE: [PHP] MySQL performance question | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-111198@lists.php.net to get a copy of this message | ||
I'm sure it's the first one. Look up the BENCHMARK() function in the
manual and see which one is faster. (MySQL manual, btw)
---John Holmes...
> -----Original Message-----
> From: Lars Olsson [mailto:lasso@lassoweb.nu]
> Sent: Sunday, August 04, 2002 4: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