Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2002
    Location
    Baltimore, MD
    Posts
    26

    Unanswered: 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

  2. #2
    Join Date
    Feb 2002
    Location
    Baltimore, MD
    Posts
    26
    I should have specified that this is a MyISAM table.
    Rob Wilkerson

  3. #3
    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

  4. #4
    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.

Posting Permissions

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