Received: from localhost (unknown [200.46.204.184]) by developer.postgresql.org (Postfix) with ESMTP id B36982E0043 for ; Tue, 22 Apr 2008 08:02:20 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 66007-04 for ; Tue, 22 Apr 2008 08:02:10 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from depesz.com (depesz.com [88.198.37.40]) by developer.postgresql.org (Postfix) with ESMTP id C1E812E002C for ; Tue, 22 Apr 2008 08:02:16 -0300 (ADT) Received: from depesz by depesz.com with local (Exim 4.63) (envelope-from ) id 1JoGGM-0005Fd-MZ; Tue, 22 Apr 2008 13:02:14 +0200 Date: Tue, 22 Apr 2008 13:02:14 +0200 From: hubert depesz lubaczewski To: Nacef LABIDI Cc: pgsql-sql@postgresql.org Subject: Re: After updating dataset the record goes to the end of the dataset Message-ID: <20080422110214.GA18721@depesz.com> Reply-To: depesz@depesz.com References: <3B256469-4A00-44C3-8EB8-F49FA9F7259A@scnat.ch> <20080422101523.GB17162@depesz.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.13 (2006-08-11) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200804/135 X-Sequence-Number: 30674 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