Subject Re: [ib-support] some index questions
Author Nando Dessena
Tom,

> Is it always better to use a generated field as a primary key?.
> Let say that in a table you can create a primary key with the first 3
> or 4 fields, will this bring a speed reduction?
> Or is it just by experience that you better can use seperate (auto
> generated) primary keys. I've read books/articles and one says you
> need to use a generated key and another one says that if you can
> avoid a generated key, you need that one...

the latter was probably and ageing article. A modern approach to
relational mapping of data calls for surrogated identifiers. With IB you
won't have any problems using them. You will almost certainly see speed
improvements and many less headaches if you do.

> if you create an index. no sorting order, will it than be slower than
> the same key with a descending or ascending order?

An index is by default ascending. An index with no sorting order cannot
exist.

> So, if I need a descending and a descending order key for that field,
> then I create 2 keys (desc, asc) or 1 key with no order.

Don't confuse indexes and keys. You don't need a key with a direction;
you may need an index with ascending or descending direction to support
your queries. It very much depends on the SQL statements you use.

> Is Firebird smart enough to use a key or do you always have to
> explecit say that it has to use that key.

Firebird is smart enough. Whether it can be smarter or not is a frequent
discussion topic.
Ciao
--
____
_/\/ando