MySQL Forums
Forum List  »  Newbie

Re: Tune that query (and multi INdexes)
Posted by: Erin ONeill
Date: June 29, 2005 04:27PM

Ok, I know that one should not SELECT *. If I change the select to look like this:
explain SELECT song, album,type FROM audio_file WHERE song = '447' AND album = '68' AND type = 'clip';
+------------+------+---------------+------+---------+-------------------+------+--------------------------+
| table | type | possible_keys | key | key_len | ref | rows | Extra |
+------------+------+---------------+------+---------+-------------------+------+--------------------------+
| audio_file | ref | song,album | song | 12 | const,const,const | 4 | Using where; Using index |
+------------+------+---------------+------+---------+-------------------+------+--------------------------+

That looks very good. But let's say I need another field too. So I do my SELECT like this:
explain SELECT song, album,type, quality FROM audio_file WHERE song = '447' AND album = '68' AND type = 'clip';
+------------+------+---------------+------+---------+-------------------+------+-------------+
| table | type | possible_keys | key | key_len | ref | rows | Extra |
+------------+------+---------------+------+---------+-------------------+------+-------------+
| audio_file | ref | song,album | song | 12 | const,const,const | 4 | Using where |
+------------+------+---------------+------+---------+-------------------+------+-------------+

and now I'm back to where I was! (though I'm making the programmers SELECT all the fields they need and not to be lazy).

am I missing something obvious?

Options: ReplyQuote


Subject
Written By
Posted
Re: Tune that query (and multi INdexes)
June 29, 2005 04:27PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.