Removing HASH Match / Inner Join

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • moldster
    New Member
    • Jul 2006
    • 18

    #1

    Removing HASH Match / Inner Join

    Hi,

    I'm at my wits end! I have two large tables one with 1.2mill one with 2.3 mill and they are very wide tables. I have a select with an inner join. All columns used in the join are contained in indexes. But it does an index scan and a massive hashmatch. Why is this? both tables have columns in the index ordered the same, all datatypes of the indexes are ints. The code looks like this.

    SELECT TblActivities.*
    FROM TblActivities
    INNER JOIN TblBookingsCrai g
    ON
    TblActivities.c lientID = TblBookingsCrai g.clientid AND
    TblActivities.c ampaignID = TblBookingsCrai g.campaignid AND
    TblActivities.S upplierID = TblBookingsCrai g.SupplierID and
    TblActivities.C reativeVersion = TblBookingsCrai g.CreativeVersi on

    Does anyone know why it won't perform an index seek?

    Cheers
    C
  • aramki
    New Member
    • Sep 2006
    • 9

    #2
    You should have the indexes on the fields you want to join, do you have them like that?

    TblActivities.c lientID = TblBookingsCrai g.clientid AND
    TblActivities.c ampaignID = TblBookingsCrai g.campaignid AND
    TblActivities.S upplierID = TblBookingsCrai g.SupplierID and
    TblActivities.C reativeVersion = TblBookingsCrai g.CreativeVersi on

    Comment

    • moldster
      New Member
      • Jul 2006
      • 18

      #3
      Hi,

      Thanks for the reply. Yes I do have the indexes identically setup on both tables. Could it be ignoring the indexes because of the size difference of the two tables? One has 1millish and the other 2.5mill ish?

      Cheers
      C

      Comment

      • senthilnathansk
        New Member
        • Aug 2007
        • 1

        #4
        Did you check the values of these columns? if they contain duplicate values or highly identical values for number of records; say for 100 records at least the indexes have same values. In this case, the index scan would be the decision that SQL optimizer might take!

        Comment

        Working...