oracle - SQL Query Performance Issue sub-query and missing parenthesis -
i have 2 questions in below query
when tried running query getting below error in oracle
performance issue i.e when run query without in clause i.e remove {select * cand_profile postal_code in } in below query taking 15 sec .how fine tune sql query ?
query
select * cand_profile postal_code in ( select zip ( select dest.id, dest.postal_code zip, acos(sin(radians(src.latitude))*sin(radians(dest.latitude))+cos(radians(src.latitude))*cos(radians(dest.latitude))*cos(radians(src.longitude)-radians(dest.longitude)))* 3959 distance post_codes dest cross join post_codes src src.id = ( select id post_codes postal_code = '60195' group id ) , ( dest.id <> src.id or dest.id = src.id ) ) group id,zip,distance having distance <= 5 order distance ))
ora-00907: missing right parenthesis 00907. 00000 - "missing right parenthesis" *cause:
*action:
the 'in' clause tends inefficient. try use join instead:
select c.* cand_profile c join ( select zip ( select dest.id,dest.postal_code zip, acos(sin ( radians( src.latitude) ) * sin ( radians ( dest.latitude )) + cos ( radians ( src.latitude)) * cos ( radians ( dest.latitude )) * cos ( radians( src.longitude ) - radians ( dest.longitude ))) * 3959 distance post_codes dest cross join post_codes src src.id = ( select id post_codes postal_code = '60195' group id ) , ( dest.id <> src.id or dest.id = src.id ) ) group id,zip,distance having distance <= 5 order distance ) on postal_code = a.zip
Comments
Post a Comment