Link to home
Start Free TrialLog in
Avatar of Rush_2112
Rush_2112

asked on

Query runs too slowly

Here's the query:

SELECT   *
      FROM NC2 a LEFT OUTER JOIN Actions b ON  a.UniqueID = b.DealerID
      WHERE  NOT EXISTS (
                     SELECT c.DealerID
                     FROM    Actions c
                     WHERE  c.DealerID = b.DealerID
                     AND       c.EventID = 1
       )

It works, but it can take over a minute to return records.  The 2 tables only have a few hundred records each.

What I need it to do is the following:

Select every record in NC2 UNLESS the value of UniqueID in NC2 matches up with a field called DealerID in a table called Actions., and then only if they match and the EventID is equal to 1.

Thanks
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Rush_2112
Rush_2112

ASKER

how do i do an explain plan?