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
LVL 1
Rush_2112Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Guy Hengel [angelIII / a3]Connect With a Mentor Billing EngineerCommented:
you need a index on Actions table, field DealerID
that should help alot.
after that, please show the explain plan of the query
0
 
Rush_2112Author Commented:
how do i do an explain plan?
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
0
All Courses

From novice to tech pro — start learning today.