oracle - SQL Query Performance Issue sub-query and missing parenthesis -


i have 2 questions in below query

  1. when tried running query getting below error in oracle

  2. 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

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -