Re: Weird indices

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Weird indices
Дата
Msg-id 9239.982730819@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Weird indices  (Joseph Shraibman <jks@selectacast.net>)
Список pgsql-general
Joseph Shraibman <jks@selectacast.net> writes:
> Why?  There is a mechanism for keeping track of which heap tuples are
> valid, why not index tuples?  It is the nature of indices to be updated
> on inserts, why not deletes?

An index is a hint: these tuples *might* be of interest to your
transaction.  It's OK for an index to point to some irrelevant tuples,
but it's useless if it fails to point to all the possibly relevant
tuples.  Therefore, it's OK to insert an index entry at the earliest
possible instant (as soon as a yet-uncommitted heap tuple is inserted);
and contrariwise the index entry can't be deleted until the heap tuple
can be proven to be no longer of interest to any still-alive transaction.

Currently, proving that a heap tuple is globally no-longer-of-interest
and removing it and its associated index tuples is the task of VACUUM.

Intermediate state transitions (eg, this tuple has been deleted by a
not-yet-committed transaction) are recorded in the heap tuple, but we
don't try to look around and update all the associated index tuples at
the same time.  Maintaining that same state in all the index tuples
would be expensive and would bloat the indexes.  An index that's not
a lot smaller than the associated heap is of little value, so extra
bits in an index entry are to be feared.

These are very fundamental system design decisions.  If you'd like
to show us the error of our ways, step right up to the plate and swing
away; but unsubstantiated suggestions that these choices are wrong are
not going to be taken with any seriousness.  Postgres has come pretty
far on the basis of these design choices.

            regards, tom lane

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

Предыдущее
От: Martijn van Oosterhout
Дата:
Сообщение: Re: two tables - foreign keys referring to each other...
Следующее
От: Christopher Sawtell
Дата:
Сообщение: Bug in my ( newbie ) mind?