Severe Query Performance Problem
I've a following sql query, which has a severe performance problem on Production server, however it is remarkably quick on Test environment where it gives the result in 1 sec. but on Production server it's result comes in 11-12 minutes which is really bad. Moreover Test is the clone of Production server. I've also checked NOT EXISTS operator instead of NOT IN but the timing is almost same. ap_invoice_distributions_all table has 413638 records.
select *
* from ap_invoices_all ap_invoices_all where invoice_id not in invoice_id not in (select invoice_id from ap_invoice_distributions_all