Re: make a unique index for foreign keys?

Поиск
Список
Период
Сортировка
От Josh Berkus
Тема Re: make a unique index for foreign keys?
Дата
Msg-id 200206121634.30493.josh@agliodbs.com
обсуждение исходный текст
Ответ на make a unique index for foreign keys?  ("Beth Gatewood" <beth@vizxlabs.com>)
Ответы Re: make a unique index for foreign keys?  ("Beth Gatewood" <beth@vizxlabs.com>)
Список pgsql-sql
Beth,

> So one quick question while I have you ;-) So those indexes would be
> non-unique indexes....I thought that I read somewhere that one shouldn't
> bother with those types of indexes (was that a total mis-statement...it
> kinda seems like it would be)

That's incorrect.  It's only in the extreme case of non-uniqueness -- for
example, 3 possible values in a table of 10,000 records -- that indexes are
useless.  In all other cases, indexes are a Good Thing.

Questions for "Shall I create an index?"
1. Will the column be part of JOIN statementents in common queries?
2. Will the column often be used in a WHERE clause?  If so, how?
3. Will the column be used in an ORDER BY clause?

If the answer to any of the above is yes, you want an index.  What *kind* of
index is a more complex topic.   But as a reference, about 50% of the columns
in most of my databases are indexed.

--
-Josh Berkus



В списке pgsql-sql по дате отправления:

Предыдущее
От: Jan Wieck
Дата:
Сообщение: Re: General trigger function
Следующее
От: "Beth Gatewood"
Дата:
Сообщение: Re: make a unique index for foreign keys?