oracle11g - Query performance issue in oracle -
i need improve query has more 8 joins , consumes lot of total tablespace.
following query:
select r.id, uc.contributor_full_name,s.code, d.text, ucs.moderation_status, v.url review r, user_contribution uc, user_contribution_status ucs, video v, description d, video_description vd, location_video lv, accommodation_video av, system s r.user_contribution_id = ucs.user_contribution_id , uc.id = ucs.user_contribution_id , uc.system_id = s.id , r.accommodation_id = av.accommodation_id or r.location_id = lv.location_id , av.video_id = v.id , lv.video_id = v.id , v.id = vd.video_id , vd.description_id = d.id;
is there better way write query?
with query it's possible oracle default whole lot of hash joins , full table scans, may or may not idea.
+1 post explain plan. until then, don't upvote answer!
i believe query equivalent this, , it's possible when @ explain plan you'll see oracle convert anyway:
select r.id ,uc.contributor_full_name,s.code ,d.text ,ucs.moderation_status ,v.url review r join user_contribution_status ucs on r.user_contribution_id = ucs.user_contribution_id join user_contribution uc on uc.id = ucs.user_contribution_id join system s on uc.system_id = s.id join accommodation_video av on r.accommodation_id = av.accommodation_id join video_description vd on v.id = vd.video_id join description d on vd.description_id = d.id join video v on av.video_id = v.id union select r.id ,uc.contributor_full_name,s.code ,d.text ,ucs.moderation_status ,v.url review r join user_contribution_status ucs on r.user_contribution_id = ucs.user_contribution_id join user_contribution uc on uc.id = ucs.user_contribution_id join system s on uc.system_id = s.id join location_video lv on r.location_id = lv.location_id join video_description vd on v.id = vd.video_id join description d on vd.description_id = d.id join video v on lv.video_id = v.id;
warning: may have made assumptions constraints (e.g. pk, fk , not null) on of id columns, esp. regards accommodation_video , location_video. removed them subclauses assumption weren't necessary - assumption may wrong.
Comments
Post a Comment