Oracle不合理的表设结构计导致执行缓慢(2)

初步看看,无非1是查视图,3是直接查表的区别,但关键是去掉Order By Vquest0_.State Asc, Vquest0_.Ask_Time Desc后两者的执行时间差不多,而加上排序后时间就有数十倍的差距,再来看看视图V_Question_Head

create or replace view v_question_head asSelect t.Accept_Id, t.Industry_Id, t.Dept_Id, t.Title, t.Question, t.Requester, t.Requester_Name, t.Ask_Time, t.Answer,              t.Answer_Man, t.Answer_Time, t.Is_Hot, t.Check_Man, t.Check_Time, t.Satisfaction, t.Satis_Reason, t.Telphone,              t.Is_Display, t.Hot_Sort, t.Check_State, t.State, t.Bbs_Id, t.Acceptor, t.Accept_Time, t.Is_Anonymous,              t.Anonymous_Email, t.Ip_Address, t.Is_Requester_Read,              (Select Count(r1.Accept_Id) From Answer_Remind r1 Where t.Accept_Id = r1.Accept_Id) As Reminded_Count,              (Select (Case                                     When Count(r2.Accept_Id) > 0 Then                                      1                                     Else                                      0                                 End                 From Answer_Remind r2                  Where t.Accept_Id = r2.Accept_Id) As Is_Reminded From Question_Head t Order By t.State Asc, t.Ask_Time Desc 

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/22794.html