Re: After updating dataset the record goes to the end of the dataset - Mailing list pgsql-sql

From hubert depesz lubaczewski
Subject Re: After updating dataset the record goes to the end of the dataset
Date
Msg-id 20080422110214.GA18721@depesz.com
Whole thread Raw
In response to Re: After updating dataset the record goes to the end of the dataset  ("Nacef LABIDI" <nacef.l@gmail.com>)
List pgsql-sql
On Tue, Apr 22, 2008 at 12:31:54PM +0200, Nacef LABIDI wrote:
> When I have tested this with SQLServer it works well, since the rows doesn't
> change position on the DB.
> I hope that you understand my issue and I will provide any explanations if
> someting isn't clear enough.

well. in postgresql rows do change position. and even in mssql depending
on position from table files is a very big mistake.

suggestion - add default "order by" by some id or timestamp column, and
modify it to fit your user preferences.

for example:

let's say that you have rows with ids: 1,2,3

by default you get them in order: 1,2,3.

if user wants to change the ordering to 2,3,1, store his preferences in
some other table and do it like this:

select t.* from table t join preferences p on t.id = p.id_in_table where
p.user = 'current user' order by p.ordering;

regards,

depesz



pgsql-sql by date:

Previous
From: "Pavan Deolasee"
Date:
Subject: Re: After updating dataset the record goes to the end of the dataset
Next
From: Padam J Singh
Date:
Subject: Re: After updating dataset the record goes to the end of the dataset