Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2007
    Posts
    130

    Unanswered: which index are right choice

    Hello ALL,

    I have two tables A and B
    Code:
    A
    Name  Department Sex
    
    
    B
    Name   GroupName  Salary
    I need to do the following query
    Code:
    SELECT 
               A.NAME, B.GroupName
     FORM
              A, B
    WHERE 
              A.Name = B.Name AND A.Department = 'Sales' AND B.GroupName='Sales'
    I wonder how to design the indexes when creating the two tables using 'CREATE TABLE' to get a better performance,

    Code:
    for Table A
    INDEX idx_NAME(NAME), INDEX idx_Department(Department) 
    OR
    INDEX idx_NAME(NAME ,Department) 
    
    
    for Table B
    INDEX idx_NAME(NAME), INDEX idx_Department(GroupName) 
    OR
    INDEX idx_NAME(NAME ,GroupName)
    Last edited by cy163; 10-24-08 at 10:38.

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    before we talk about indexes, what are the primary keys of those tables?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •