Re: Not exists performance problem...

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: ashish (mittalashish_at_yahoo.com)
Date: 02/21/04


Date: Fri, 20 Feb 2004 19:45:19 -0800

It is usually best not to use the "not in" clause for large tables. I
would have posed the query sas follows:
select * from (
select ...
 from T1 inner join T2 ...
LEFT OUTER JOIN FT1 on FT1.A = C1.A and FT1.B=C2.B
) where FT1.A is null
On Wed, 18 Feb 2004 15:59:27 -0500, Jéjé <willgart@_A_hAotmail_A_.com>
wrote:

> Hi,
>
> I've a query to load my data warehouse, like this :
> select C1, C2, C3....
> from T1 inner join T2 ......
> where not exists (Select * from FT1 where FT1.A = C1.A and FT1.B=C2.B...)
>
> my T1 table (the biggest one) has 240 000 records
> my FT1 contain only 20 000 records.
>
> the result is near 160 000 records and takes 26 minutes to be
> completed!!!
>
> The query plan estimated that the query will return only 60 records!!!
> So there is a big mistake between the real number and the query plan, so
> I
> presume this is the problem because SQL Server don't optimize correctly
> my
> query.
> But my statistics are goods and my index are goods.
>
> The index tuning wizard don't find anything to optimize.
>
> What can I do?
> Any guide?
> Thanks.
>
> Jerome.
>
>
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.591 / Virus Database: 374 - Release Date: 2004-02-17
>
>

-- 
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/


Relevant Pages

  • Summing a Query
    ... I have a query that calculates the total cost of goods of each product ... (COGS = Price * Inventory). ...
    (comp.databases.ms-access)
  • Not exists performance problem...
    ... The query plan estimated that the query will return only 60 records!!! ... So there is a big mistake between the real number and the query plan, ... But my statistics are goods and my index are goods. ... The index tuning wizard don't find anything to optimize. ...
    (microsoft.public.sqlserver.server)
  • Not exists performance problem...
    ... The query plan estimated that the query will return only 60 records!!! ... So there is a big mistake between the real number and the query plan, ... But my statistics are goods and my index are goods. ... The index tuning wizard don't find anything to optimize. ...
    (microsoft.public.sqlserver.programming)
  • Not exists performance problem...
    ... The query plan estimated that the query will return only 60 records!!! ... So there is a big mistake between the real number and the query plan, ... But my statistics are goods and my index are goods. ... The index tuning wizard don't find anything to optimize. ...
    (microsoft.public.sqlserver.datawarehouse)
  • RE: Count Criteria in a Report or Query
    ... I have another table that contains ptdata, location, lengthofstay, ... dischargedate. ... I created a query that allows you to enter a date range. ... know how many Very Goods, Goods, etc per location. ...
    (microsoft.public.access.queries)