Re: Index creation

From: Jan.Hidders <hidders_at_hcoss.uia.ac.be>
Date: 9 Aug 2002 10:59:19 +0200
Message-ID: <3d538467$1_at_news.uia.ac.be>


In article <73d921e1.0208081525.1bf53b1e_at_posting.google.com>, Flávio Maciel <flaviorm_at_portoweb.com.br> wrote:
>Consider a basic many-to-many relationship where you have two foreign
>keys that are also the primary key of this relationship table.
>My question is: what's are the differences and implications of:
>- building an index for the primary key and each foreign key?
>- building an index just for thew primary key?
>- building an index just for the foreign keys?
>
>If I have the index for the primary key, is it needed to have indexes
>for each foreign key individually?

That depends a bit on the database and the used indexing techniques. Usually with B-trees and sorted indexes databases know that they can use an index on (A, B, C) as if it was an index on (A, B) or (A). So if you already have a primary key (A, B) then you only need an extra index on (B).

  • Jan Hidders
Received on Fri Aug 09 2002 - 10:59:19 CEST

Original text of this message