Re: MySQL performance question
| From: | Richard Lynch | Date: | Mon, 05 Aug 2002 07:18:43 +0000 |
| Subject: | Re: MySQL performance question | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-111176@lists.php.net to get a copy of this message | ||
>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
Try it and see.
MySQL has a very nice 'explain' (?) or something like that built-in which
will analyze your queries and tell you more than you ever wanted to know
about their efficiency. http://mysql.com
Note that you didn't say whether you had made an index (aka key) for this
column, which may affect your answer.
Also note that you're wasting your time with this question unless you have a
*LOT* of rows. I mean a *LOOOOOOT* of rows. Try it and see.
--
Like Music? http://l-i-e.com/artists.htm
I'm looking for a PRO QUALITY two-input sound card supported by Linux (any
major distro). Need to record live events (mixed already) to stereo
CD-quality. Soundcard Recommendations?
Software to handle the recording? Don't need fancy mixer stuff. Zero (0)
post-production time. Just raw PCM/WAV/AIFF 16+ bit, 44.1KHz, Stereo
audio-to-disk.