查询性能问题 - 不在

时间:2017-01-08 18:41:17

标签: peoplesoft

下面的查询是由其他人创建的,但运行时间很长,因此需要提高性能。你能告诉我一个更好的方法吗?

Select * from ps_vendor G where G.vendor_id NOT IN (SELECT vendor_id 
                               FROM   ps_voucher_line 
                               WHERE  vendor_id <> '70830' 
                                      AND cntrct_id <> ' ' 
                                      AND vendor_id NOT IN (SELECT vendor_id 
                                                            FROM   ps_cntrct_hdr 
                                                            WHERE 
                                          cntrct_type = 'AP')) 

1 个答案:

答案 0 :(得分:0)

请尝试使用内部连接条件,如下面的显示

Select G.* from ps_vendor G 
       inner join ps_voucher_line  pvl
            on G.vendor_id = pvl.vendor_id and pvl.vendor_id  <> '70830'
        inner join ps_cntrct_hdr pch
            on  (pch.vendor_id <> pvl.vendor_id and pch.cntrct_type = 'AP')
    where pv.cntrct_id <> ' '  

尝试加入条件的不同变化!!

好的是您有子查询来验证结果。