Changing SQL NOT IN to JOINS -


enter image description here

hello guys,

our aim script insert missing pairs of product - taxcategory in intermediate table (producttaxcategory)

the following script correctly working trying find way optimize it:

insert producttaxcategory     (producttaxcategory_taxcategoryid,producttaxcategory_productid) select      taxcategoryid     ,productid  product pr cross join taxcategory tx pr.productid not in  (     select producttaxcategory_productid     producttaxcategory )  or pr.productid in  (     select producttaxcategory_productid      producttaxcategory )  , tx.taxcategoryid not in  (     select producttaxcategory_taxcategoryid      producttaxcategory      producttaxcategory_productid = pr.productid  ) 

how can optimize query ?

try (full statement now):

insert producttaxcategory     (producttaxcategory_taxcategoryid,producttaxcategory_productid) select taxcategoryid, productid  product pr cross join taxcategory tx not exists        (select 1 producttaxcategory          producttaxcategory_productid     = pr.productid         ,   producttaxcategory_taxcategoryid = tx.taxcategoryid) 

exists (select 1 ... id=...) better alternative in (select id ... ) constructs.


Comments

Popular posts from this blog

java - Solr query version issue: Invalid version or the data in not in 'javabin' format -

Hard vs. Soft Water: What's The Difference?

The Ten Most Livable Cities In The World