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 > Performance & Indexing Question

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-11-07, 15:07
rwilkerson rwilkerson is offline
Registered User
 
Join Date: Feb 2002
Location: Baltimore, MD
Posts: 26
Performance & Indexing Question

I have a table with a dual primary key (impression_id, element_id). Are those fields indexed? Individually or as a combo index? In addition to using the impression_id field in a join, I need to access element_id in the where clause of a big query. Would it offer any benefit at all to index element_id independently?

Any guidance would be greatly appreciated.

Thanks.
__________________
Rob Wilkerson
Reply With Quote
  #2 (permalink)  
Old 04-11-07, 15:07
rwilkerson rwilkerson is offline
Registered User
 
Join Date: Feb 2002
Location: Baltimore, MD
Posts: 26
I should have specified that this is a MyISAM table.
__________________
Rob Wilkerson
Reply With Quote
  #3 (permalink)  
Old 04-11-07, 15:08
rwilkerson rwilkerson is offline
Registered User
 
Join Date: Feb 2002
Location: Baltimore, MD
Posts: 26
And, just because my head isn't screwed on straight today, I'm on MySQL 5. Sorry for taking so long to share relevant information.
__________________
Rob Wilkerson
Reply With Quote
  #4 (permalink)  
Old 04-12-07, 04:17
aschk aschk is offline
Registered User
 
Join Date: Mar 2007
Location: 636f6d7075746572
Posts: 770
I believe they are indexed as a dual unit, thus as index(impression_id,element_id). And in answer to your question : I'm not 100% but I believe that yes, you will benefit from indexing only element_id as your where clause should use this index properly. Use EXPLAIN to find out where your indexes are being used in your queries. The path execution planner however might work out that as (impression_id,element_id) is a primary key and therefore unique it CAN use that to limit with your where clause.
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