Re: problem with select after updating

From: Doug McNaught <doug(at)wireboard(dot)com>
To: "Raul DAVIDOVICH" <R(dot)DAVIDOVICH(at)cvitkovic-ac(dot)fr>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: problem with select after updating
Date: 2001-12-10 18:56:06
Message-ID: m3k7vu52gp.fsf@belphigor.mcnaught.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Raul DAVIDOVICH" <R(dot)DAVIDOVICH(at)cvitkovic-ac(dot)fr> writes:

> Hello,
>
> I'm having a problem when updating a row.. after comiting the change,
> the row appears at the end of the list, and from there on, it stays there
> until the next update.

This is normal, see below.

> This happens when using both JDBC or psql. Normally, rows shouldn't
> change the order after updates. Am I messing it up with the indexes?

There is no defined order for storing rows in PostgreSQL. If you want
query results in a specific order use an ORDER BY clause.

What's happening is that PostgreSQL never overwrites a row when it's
updated (since other transactions may still need to see the old row),
so it creates a new one and marks the old as invalid. The new row
will usually come at the end of a set of query results.

ORDER BY is your friend.

-Doug
--
Let us cross over the river, and rest under the shade of the trees.
--T. J. Jackson, 1863

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Doug McNaught 2001-12-10 18:58:33 Re: PostgreSQL Outer Joins
Previous Message Robert B. Easter 2001-12-10 18:52:54 Re: problem with select after updating