List:General Discussion« Previous MessageNext Message »
From:Dan Nelson Date:April 24 2006 6:09pm
Subject:Re: Table design; 2-column index
View as plain text  
In the last episode (Apr 24), Fan, Wellington said:
> Thanks; I was really trying to ask about the potential performance
> gain, however. I don't care so much about the UNIQUEness, but the
> INDEXness.
> 
> See, I am wondering if I create an 2-column index wiht fk1 as the
> first component, will that index help me if I am refering fk2 in my
> query?

You mean like "SELECT fk2 FROM t WHERE fk1 IN (1,2,3,4)"?  Yes.  You
can verify this by looking at the EXPLAIN plan for the query.  If it
says "Using index" in the Extra column, it means all the fields mysql
needs is in the index and it won't have to fetch row data.

-- 
	Dan Nelson
	dnelson@stripped
Thread
Table design; 2-column indexWellington Fan24 Apr
  • Re: Table design; 2-column indexDan Nelson24 Apr
RE: Table design; 2-column indexWellington Fan24 Apr
Re: Table design; 2-column indexDan Nelson24 Apr