Sunday 15 July 2012

MySQL JOIN Query Index optimization -



MySQL JOIN Query Index optimization -

i have query. assuming no index created yet, how can optimize using index query runs faster? how create index?

select c.company_name, c.company_id companies c bring together users u using(companyid) bring together jobs j using(userid) bring together useraccounts ua using(userid) j.jobid = 10;

any help appreciated.

you should have indexes on columns used in join clauses. can create indexes either create index or alter table commands:

create index u_companyid on users (companyid); alter table users add together index (companyid);

note primary keys of tables indexed, don't need add together index explicitly.

mysql join indexing

No comments:

Post a Comment