Subject Re: [ib-support] Is a joined query faster than a subquery, or doesn't it matter?
Author Helen Borrie
At 05:30 PM 14-02-01 +0100, you wrote:
> > I read somewhere that Interbase creates an index automatic for primary,
> > foreign and unique keys.
> >
>
>Primary and Foreign-Keys ARE indices.

In dBase, you use indices to form keys because it doesn't have a mechanism to constrain a field to be a key.

In InterBase, a key is a special kind of constraint enabling certain requirements and behaviours on the column(s) carrying the constraint. In the process of creating a key constraint, IB *also* creates an ascending index on the same column. In the case of a primary key, the index is unique. If you don't apply a PRIMARY KEY or FOREIGN constraint on the column, it won't be a key, even if you have created an index for it.

You can cause problems in queries if you define an ascending index on a key column yourself. The optimizer doesn't know which index to use, so it doesn't use one at all.

Cheers,
Helen

All for Open and Open for All
InterBase Developer Initiative ยท http://www.interbase2000.org
_______________________________________________________