From: | Martijn van Oosterhout <kleptog(at)svana(dot)org> |
---|---|
To: | Tony Caduto <tony_caduto(at)amsoftwaredesign(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: weirdness with the a sql update |
Date: | 2005-08-04 14:35:28 |
Message-ID: | 20050804143522.GA25982@svana.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Thu, Aug 04, 2005 at 09:19:44AM -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?
Table in SQL don't have an implicit order. If you want the rows in a
particular order, you need to use ORDER BY.
> Why is Postgresql changing the ordering of the results after a simple
> update?
Because it's silly to order stuff if you didn't ask for a particular
order. Waste of CPU cycles.
> It almost looks like the record is being dropped and then readded to the
> end.
Under the hood, that's what happens. But it might appear at the end, in
the middle, anywhere. If want an order, use ORDER BY, otherwise it'll
be random.
Hope this helps,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.
From | Date | Subject | |
---|---|---|---|
Next Message | Douglas McNaught | 2005-08-04 14:41:36 | Re: weirdness with the a sql update |
Previous Message | Tom Lane | 2005-08-04 14:29:03 | Re: What happens when wal fails? |