select trandate, serseqno, acctno, voukind,vouno, memomsg, cdflag, amount, trancode, oppaccno, oppacctname, flag
 from glsinacctlist a 
where cancelflag='0'
 and trancode not in ( '548300', 'T00000' ) and acctno='6217000088103047' and trandate='2017-04-17'
 and ( ( (trancode = 'TC0001' or trancode = 'TP0001') and ( flag = '1' or flag = '2' ) ) or (trancode <> 'TC0001' and trancode <> 'TP0001' and flag not in ('B','C','D','E') ) ) 
and not exists ( select 1 from GLSINACCTLIST where acctno=a.acctno and trandate=a.trandate and cancelstan=a.serseqno and cancelflag='1') order by a.serseqno这条语句在执行时,有的时候很快,有的时候很慢,一执行cpu就飚到100%
表glsinacctlist 中大概有8000万条数据
求大神门给个优化建议,最好能解释下为什么,在下小白啊,下周上线
急急急急!