sql - Optimize a simple JOIN or IN query -
i have query:
select distinct id, label bbproduct_cust custno in (select custno customer slsrptgrp = '1996') , deptno = '0' order label asc
explain
shows
id select_type table type possible_keys key key_len ref rows 1 primary bbproduct_cust ind_deptno 91834 using where; using temporary; using filesort 2 dependent subquery customer ref primary,ind_slsrptgrp ind_slsrptgrp 3 const 4 using
it takes 2-3 seconds, , need optimized.
what options have?
use inner join, rather in select
something like
select distinct id, label bbproduct_cust inner join customer on bbproduct_cust.custno = customer.custno slsrptgrp = '1996' , deptno = '0' order label asc
Comments
Post a Comment