0

Hi I am not understanding , why the subquery of given query is converting into dependent subquery.

Although the subquery is not dependent(not using primary query table) on main query.

I know that this query can be optimized using joins,but here i just want to know the reason of this

EXPLAIN SELECT id  FROM  `cab_request_histories` 
WHERE cab_request_histories.id = any(SELECT id
                                     FROM cab_requests
                                     WHERE cab_requests.request_type =  'pickup')

id   select_type      table type           possible_keys     key               key_len  ref rows Extra
1    PRIMARY    cab_request_histories   index             NULL             PRIMARY  4   NULL    20                       

2    DEPENDENT       SUBQUERY          cab_requests unique_subquery    PRIMARY  PRIMARY 4 func  1
2
Contributors
2
Replies
42
Views
4 Years
Discussion Span
Last Post by sathishnadu
0

I know that this query can be optimized using joins,but here i just want to know the reason of this

Are you asking for a opinion or a suggestion or an answer?

Did you write this query or you find it online?

The way you post this question it seems you are not sure how this works and my impression is that you didn't write this query and I don't know what you are trying to do or get out of this?

You can read this it will explain subqueries and joins in mysql (How to optimize subqueries and joins in MySQL):

http://www.xaprb.com/blog/2006/04/30/how-to-optimize-subqueries-and-joins-in-mysql/

You can also read this it will give you tips & techniques on optimize subqueries (Optimization Tips & Techniques):

http://sqlserverpedia.com/wiki/Optimization_Tips_%26_Techniques

Edited by LastMitch: grammer

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.