NYCPHP Meetup

[nycphp-talk] Re: MySQL doubt

Faber Fedor faber at linuxnj.com
Sat Jan 15 00:09:15 EST 2005


On 14/01/05 21:16 -0500, Ophir Prusak wrote:
> As long as we're on the subject, could someone shed some light on this behavior?
> It caused me a good amount of hair pulling until I realized what mysql
> was doing.
> 
> Why doesn't MySQL use the primary key in the second query?

I may be missing something here, but why would MySQL use the PK in the second
query?  You didn't ask it to. 

> I would think that count doesn't care what column I use, but obviously it does.

Why would you think that? count doesn't care what column you use, but
the optimizer will use an index if it is available.  If an index is not
available, it uses the raw data (read: column).


-- 
 
Regards,
 
Faber                     

Linux New Jersey: Open Source Solutions for New Jersey
http://www.linuxnj.com






More information about the talk mailing list