Board index » delphi » Interbase Indexes on Primary and Foreign keys.

Interbase Indexes on Primary and Foreign keys.

Quote
Matthew Pascoe wrote in message <68p0mb$1...@forums.borland.com>...
>I am using Interbase 4.2 for NT. In my database creation script I have
>manually created an index for every primary and foreign key in each table.
I
>have just read somewhere that Interbase automatically generates these. Is
>this true? If so, what negative effects will these additional duplicate
>indexes cause.
>Thanks,
>Matthew Pascoe.

I used to work with IB 4.2 and make a lot of tables and primary and foreign
keys, but i never heard about IB genrating them, maybe if you put the same
field name in two tables but i'm not sure...because  how IB does to find the
master and the detail table ?

Don't be afraid because you can't create two primary key on the same table!
So... no problems.

If you put indexes on indexed fields nothing will happen except that when
inserting it will update the two indexes, and then you will lose time and
space.

Enjoy!

 

Re:Interbase Indexes on Primary and Foreign keys.


Quote
Jerome Fillon wrote:

> Matthew Pascoe wrote in message <68p0mb$1...@forums.borland.com>...
> >I am using Interbase 4.2 for NT. In my database creation script I have
> >manually created an index for every primary and foreign key in each table.
> I
> >have just read somewhere that Interbase automatically generates these. Is
> >this true? If so, what negative effects will these additional duplicate
> >indexes cause.
> >Thanks,
> >Matthew Pascoe.

> I used to work with IB 4.2 and make a lot of tables and primary and foreign
> keys, but i never heard about IB genrating them, maybe if you put the same
> field name in two tables but i'm not sure...because  how IB does to find the
> master and the detail table ?

> Don't be afraid because you can't create two primary key on the same table!
> So... no problems.

> If you put indexes on indexed fields nothing will happen except that when
> inserting it will update the two indexes, and then you will lose time and
> space.

This sage piece of advice is unfortunately very incorrect for Interbase.  In
fact, you should do precisely the opposite and remove the explicitly created
indexes.

IB does create an index on the table to manage a foreign-key, a primary key,
or a referential integrity relationship.  Therefore you do not need to create
one.  But, more to the point, you should NOT create one.

The IB4 query-optimizer tends to generate plans that use all available
indexes, even if two or more of these indices are redundant and even if this
causes the query to slow down - which it does.

There are a number of highly relevant papers concerning Interbase at:
http://www.mers.com/

Re:Interbase Indexes on Primary and Foreign keys.


I am using Interbase 4.2 for NT. In my database creation script I have
manually created an index for every primary and foreign key in each table. I
have just read somewhere that Interbase automatically generates these. Is
this true? If so, what negative effects will these additional duplicate
indexes cause.
Thanks,
Matthew Pascoe.

Re:Interbase Indexes on Primary and Foreign keys.


Mike & Nancy Robinson wrote in message <34B0484E....@primenet.com>...

Quote
>Jerome Fillon wrote:

>> Matthew Pascoe wrote in message <68p0mb$1...@forums.borland.com>...
>> >I am using Interbase 4.2 for NT. In my database creation script I have
>> >manually created an index for every primary and foreign key in each
table.
>> I
>> >have just read somewhere that Interbase automatically generates these.
Is
>> >this true? If so, what negative effects will these additional duplicate
>> >indexes cause.
>> >Thanks,
>> >Matthew Pascoe.

>> I used to work with IB 4.2 and make a lot of tables and primary and
foreign
>> keys, but i never heard about IB genrating them, maybe if you put the
same
>> field name in two tables but i'm not sure...because  how IB does to find
the
>> master and the detail table ?

>> Don't be afraid because you can't create two primary key on the same
table!
>> So... no problems.

>> If you put indexes on indexed fields nothing will happen except that when
>> inserting it will update the two indexes, and then you will lose time and
>> space.

>This sage piece of advice is unfortunately very incorrect for Interbase.
In
>fact, you should do precisely the opposite and remove the explicitly
created
>indexes.

>IB does create an index on the table to manage a foreign-key, a primary
key,
>or a referential integrity relationship.  Therefore you do not need to
create
>one.  But, more to the point, you should NOT create one.

>The IB4 query-optimizer tends to generate plans that use all available
>indexes, even if two or more of these indices are redundant and even if
this
>causes the query to slow down - which it does.

>There are a number of highly relevant papers concerning Interbase at:
>http://www.mers.com/

Mike & Nancy,

Thanks for the good advice. I have checked out the website and found a
mountain of valuable info. Will definitely be returning there.
Thanks again.
Matthew.

Other Threads