469,110 Members | 2,009 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,110 developers. It's quick & easy.

Record order change after update

Hello list,

After update a column on a table, that row goes to the top when I do a
select from that table without any order, is that the expected behavior
in postgresql? is there a way to prevent it?

Thanks in advance.

Josué Maldonado

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org

Nov 23 '05 #1
7 3052
On Tue, Mar 02, 2004 at 04:12:05PM -0600, Josué Maldonado wrote:
After update a column on a table, that row goes to the top when I do a
select from that table without any order, is that the expected behavior
in postgresql?
Yes.
is there a way to prevent it?


No. Use ORDER BY.

--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"Los dioses no protegen a los insensatos. Éstos reciben protección de
otros insensatos mejor dotados" (Luis Wu, Mundo Anillo)

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Nov 23 '05 #2
My understanding of RDBMs:

you will get all information as indicated by the query in an unsorted order.
Sometimes you get the same order; sometimes you do not.

To ensure expected ordering you must use the ORDER keyword.


Quoting Josué Maldonado <jo***@lamundial.hn>:
Hello list,

After update a column on a table, that row goes to the top when I do a
select from that table without any order, is that the expected behavior
in postgresql? is there a way to prevent it?

Thanks in advance.

Josué Maldonado

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org



---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 23 '05 #3
Clinging to sanity, jo***@lamundial.hn (Josué Maldonado) mumbled into her beard:
After update a column on a table, that row goes to the top when I do a
select from that table without any order, is that the expected
behavior in postgresql? is there a way to prevent it?


Prevent what?

SQL returns unordered sets of data unless you specifically impose an
order using an ORDER BY clause.

Did PostgreSQL ignore your ORDER BY clause? If so, that would be a
problem worth reporting.

But if your query did not impose an ORDER BY clause, it is entirely
proper for the database engine to return data in whatever order it
finds most convenient.
--
If this was helpful, <http://svcs.affero.net/rm.php?r=cbbrowne> rate me
http://cbbrowne.com/info/sap.html
"When people understand what Microsoft is up to, they're outraged."
-- Tim O'Reilly, President, O'Reilly & Associates
Nov 23 '05 #4
From the relational point of view, tuples in a relation are sets, and
sets have no ordering.
That's why you should never trust how tuples are ordered (on any
relational database, not just postgreSQL), and if you care about
ordering you should always use the ORDER BY clause.

On Tue, 2004-03-02 at 19:12, Josué Maldonado wrote:
Hello list,

After update a column on a table, that row goes to the top when I do a
select from that table without any order, is that the expected behavior
in postgresql? is there a way to prevent it?

Thanks in advance.

Josué Maldonado



---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (FreeBSD)

iD8DBQBAyGbt21dVnhLsBV0RAidKAJ9xx8/wIzvbN1J9LW9rPhjgS63Z/QCfQ76x
/PKiAQFPz4sBlJ9Nt56bG+I=
=3QAs
-----END PGP SIGNATURE-----

Nov 23 '05 #5
From the relational point of view, tuples in a relation are sets, and
sets have no ordering.
That's why you should never trust how tuples are ordered (on any
relational database, not just postgreSQL), and if you care about
ordering you should always use the ORDER BY clause.

On Tue, 2004-03-02 at 19:12, Josué Maldonado wrote:
Hello list,

After update a column on a table, that row goes to the top when I do a
select from that table without any order, is that the expected behavior
in postgresql? is there a way to prevent it?

Thanks in advance.

Josué Maldonado



---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (FreeBSD)

iD8DBQBAyGbt21dVnhLsBV0RAidKAJ9xx8/wIzvbN1J9LW9rPhjgS63Z/QCfQ76x
/PKiAQFPz4sBlJ9Nt56bG+I=
=3QAs
-----END PGP SIGNATURE-----

Nov 23 '05 #6
Franco Bruno Borghesi <fr****@akyasociados.com.ar> writes:
>From the relational point of view, tuples in a relation are sets, and

sets have no ordering.
That's why you should never trust how tuples are ordered (on any
relational database, not just postgreSQL), and if you care about
ordering you should always use the ORDER BY clause.
On Tue, 2004-03-02 at 19:12, Josué Maldonado wrote:

Hello list,

After update a column on a table, that row goes to the top when I do a
select from that table without any order, is that the expected behavior
in postgresql? is there a way to prevent it?


The paragraph you quoted above answers your question. Use ORDER BY if
you want a definite order out of a SELECT query.

-Doug

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 23 '05 #7
Franco Bruno Borghesi <fr****@akyasociados.com.ar> writes:
>From the relational point of view, tuples in a relation are sets, and

sets have no ordering.
That's why you should never trust how tuples are ordered (on any
relational database, not just postgreSQL), and if you care about
ordering you should always use the ORDER BY clause.
On Tue, 2004-03-02 at 19:12, Josué Maldonado wrote:

Hello list,

After update a column on a table, that row goes to the top when I do a
select from that table without any order, is that the expected behavior
in postgresql? is there a way to prevent it?


The paragraph you quoted above answers your question. Use ORDER BY if
you want a definite order out of a SELECT query.

-Doug

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 23 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Richard C Buchanan | last post: by
2 posts views Thread by Phil Stanton | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by kglaser89 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.