Re: SQL Question

From: Saad Ahmad <sahmad_at_mfa.com>
Date: 1995/09/21
Message-ID: <43si7l$d3d_at_homer.alpha.net>#1/1


jack (jalford_at_immcms1.redstone.army.mil) wrote:
> I'm trying to count the differences of one column in
> two identical tables (except for the data) ...
> I've tried
> select count(barcode_number) from property_temp
> where
> barcode_number not in (select barcode_number from property)
> but it takes about 15 minutes for this to run ....

select count(barcode_number)
from property_temp t
where

       not exists ( select 'x'
                   from    property p
                   where
                           p.barcode_number = t.barcode_number 
                  );

property.barcod_number should be indexed.

how many rows does the property_temp have; that table needs a full table scan?

--
**************************************************************
*                          Saad Ahmad                        *
*                          McHugh Freeman & Associates, Inc. *
*                          Ph:  (414) 798-8606 Ext. 457      *
*                          Fax: (414) 798-8619               *
*                          E-Mail: sahmad_at_mfa.com            *
**************************************************************
Received on Thu Sep 21 1995 - 00:00:00 CEST

Original text of this message