Select req3 sr_num, req3 created, req3. Sr_stat_id, req2. X_owner_dept, req4. X_partner_bureau
The from temp_v_SR_HIS req2, temp_v_srv_req req3, temp_v_org_ext req4,
(
SELECT * FROM
(SELECT a.r ow_id, ROW_NUMBER () OVER (PARTITION BY Amy polumbo ar_row_id ORDER BY a.c reated) RN
The FROM (select s2 row_id, s2. Par_row_id, s2. Created
Temp_v_SR_HIS from temp_v_SRV_REQ s1, s2
where s2. X_ACT_STR_TIME & gt;=trunc (sysdate) and s2. X_ACT_STR_TIME & lt;=trunc (sysdate + 1) - 1/24/60/60
//commentAnd s1. X_sr_category='complaints'
And s1. Row_id=s2. Par_row_id
And s2. X_old_value='https://bbs.csdn.net/topics/to be processed'
Group by s2. Par_row_id, s2 row_id, s2. Created
) a
) WHERE RN req1=1)
Where req2. Row_id=req1. Row_id
And req3. Row_id=req2. Par_row_id
And req2. X_owner_dept=req4. Name
S1='Y' and req4. Int_org_flg) group by s1. X_partner_bureau order by count (1) desc
The SQL query to 100 seconds,
Comments above this line if the s2 X_ACT_STR_TIME this time field to s1. ACT_OPEN_DT fields (and time), the query is second query
Inside the S1 and S2 is similar to the amount of data,
Pray god to solve how to optimize SQL
CodePudding user response:
Do you put the first S2 subquery, filter the data, the association again?CodePudding user response:
Both the index of the situation, whether there are indexes, whether to have statistical analysis of the latest informationIs there any difference view of the two execution plans
CodePudding user response:
The s2 subquery is very slowCodePudding user response:
The best execution planCodePudding user response:
what do you want to stick the execution plan out ah, otherwise unreadable, generally slow SQL execution, are the problems of index, reasonable create indexes help SQL performance improvement oh