MySQL Forums
Forum List  »  Optimizer & Parser

Re: Optimizing query with multiple joins
Posted by: EM Ayllon
Date: May 30, 2006 07:15AM

OK. Some news here

I have tried modifying the query by using correlated and uncorrelated subqueries. I obtained improved results but I wasn't too impressed with the execution time.

I have arrived to the following expression using equijoins which is about 3 times better than using subqueries and much much better than the query previously posted, which is good. What is bad is that I can not get my head around why this equijoin based query delivers such improvement in comparison with the left joins approach apart from the fact that the optimizer seems to have changed the execution order. Is this then the only reason that explains the performance boost?

Here is the new query and the explain:

select nombre,nombre,fecha,descripcion,cv,experiencia,password,cookie,visitas,email,directorio,cuenta,poremail,url,lasttime, edad,doc,id, group_concat
(distinct wc.place),group_concat(ss.sector),wc2.place from candidatos_new, shared.worldwide_codes wc, candidatos_locations_wanted clw, shared.sectors ss, ca
ndidatos_sectores cs, shared.worldwide_codes wc2 where wc.code = clw.location_wanted and clw.candidato = id and ss.code =cs.sector and cs.candidato =id and
wc2.code = provincia and clw.location_wanted = 102004001 group by id;

Explain:

| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra
|
+----+-------------+----------------+--------+---------------------------+-----------------+---------+------------------------------------+------+-----------
----------------------+
| 1 | SIMPLE | wc | const | code | code | 5 | const | 1 | Using temp
orary; Using filesort |
| 1 | SIMPLE | clw | ref | candidato,location_wanted | location_wanted | 5 | const | 510 | Using wher
e |
| 1 | SIMPLE | candidatos_new | eq_ref | PRIMARY,provincia | PRIMARY | 4 | 102001001.clw.candidato | 2 |
|
| 1 | SIMPLE | wc2 | ref | code | code | 5 | 102001001.candidatos_new.provincia | 19 | Using wher
e |
| 1 | SIMPLE | cs | ref | sector,candidato | candidato | 5 | 102001001.candidatos_new.id | 11 | Using wher
e |
| 1 | SIMPLE | ss | ref | code | code | 5 | 102001001.cs.sector | 17 | Using wher
e |

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: Optimizing query with multiple joins
2276
May 30, 2006 07:15AM


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.