Re: weirdness with the a sql update

Поиск
Список
Период
Сортировка
От Sven Willenberger
Тема Re: weirdness with the a sql update
Дата
Msg-id 1123167072.21749.4.camel@lanshark.dmv.com
обсуждение исходный текст
Ответ на weirdness with the a sql update  (Tony Caduto <tony_caduto@amsoftwaredesign.com>)
Список pgsql-general
On Thu, 2005-08-04 at 09:19 -0500, Tony Caduto wrote:
> Hi,
>
> I just noticed this, if I do a update like this:
>
> update new_requests set name = 'tony' where request_id = 2
>
> If I do a select * from new_requests that record I just updated is now
> at the bottom , before the update it was at the top?
>
> Why is Postgresql changing the ordering of the results after a simple
> update?
> It almost looks like the record is being dropped and then readded to the
> end.
>
> Thanks,
>
If I understand MVCC correctly, a "new" tuple is actually created and
the "old" tuple is marked with an effective "end" transaction id (or
marked "dead" for any transactions with an id greater than the
transaction id that updated that particular tuple). Your subsequent
select then sees the "new" tuple and, in natural order, it would appear
at the bottom. Vacuuming is the process by which these "old" tuples are
examined and, if there are no transactions open with an id less than the
"end" transaction id associated with that dead tuple, it is removed (or
the space is marked as available for a new tuple to be written).

Sven


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

Предыдущее
От: Douglas McNaught
Дата:
Сообщение: Re: weirdness with the a sql update
Следующее
От: Michael Fuhr
Дата:
Сообщение: Re: weirdness with the a sql update