If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > which index are right choice

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-24-08, 09:32
cy163 cy163 is offline
Registered User
 
Join Date: Apr 2007
Posts: 127
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 09:38.
Reply With Quote
  #2 (permalink)  
Old 10-24-08, 09:58
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
before we talk about indexes, what are the primary keys of those tables?
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On