Re: What order in primary key definition ?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: What order in primary key definition ?
Дата
Msg-id 5574.1154003975@sss.pgh.pa.us
обсуждение исходный текст
Ответ на What order in primary key definition ?  (franck.routier@axege.com)
Список pgsql-novice
franck.routier@axege.com writes:
> I am wondering if the order in which primary key fields are ordered has an
> impact on performance...

Putting the more specific key first would make for a small improvement
in the performance of the index, because key comparisons would more
often be able to make a decision after comparing the first column and
not have to compare the second.  This is not a big deal though.

What I'd counsel asking yourself is whether you're ever going to search
the table with only one of the columns specified, and if so put that one
first.  This will save needing a second index.  If you need to search
by *both* columns independently, then you will need two indexes anyway,
one on (a,b) and one on (b) --- see
http://www.postgresql.org/docs/8.1/static/indexes-multicolumn.html

            regards, tom lane

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

Предыдущее
От: Sue Fitt
Дата:
Сообщение: pg_dump ordering in 8.1.3
Следующее
От: Tom Lane
Дата:
Сообщение: Re: pg_dump ordering in 8.1.3