X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 70481DAECF for ; Tue, 22 Nov 2005 05:29:08 -0400 (AST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 60059-02 for ; Tue, 22 Nov 2005 09:29:09 +0000 (GMT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from mail.metronet.co.uk (mail.metronet.co.uk [213.162.97.75]) by svr1.postgresql.org (Postfix) with ESMTP id CAD3BDACD9 for ; Tue, 22 Nov 2005 05:29:05 -0400 (AST) Received: from mainbox.archonet.com (84-51-143-99.archon037.adsl.metronet.co.uk [84.51.143.99]) by smtp.metronet.co.uk (MetroNet Mail) with ESMTP id 7C0C0417B67; Tue, 22 Nov 2005 09:29:02 +0000 (GMT) Received: from [192.168.1.17] (client17.office.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id 5B75A15EA4; Tue, 22 Nov 2005 09:29:07 +0000 (GMT) Message-ID: <4382E4E2.2050601@archonet.com> Date: Tue, 22 Nov 2005 09:29:06 +0000 From: Richard Huxton User-Agent: Mozilla Thunderbird 1.0.7 (X11/20051013) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Richard Huxton Cc: gry@ll.mit.edu, pgsql-sql@postgresql.org Subject: Re: tid_le comparison for tuple id (ctid) values? References: <20051121160016.282c66c2.gry@ll.mit.edu> <4271.1132607968@sss.pgh.pa.us> <20051121203527.5378122b.gry@ll.mit.edu> <4382E15C.5070206@archonet.com> In-Reply-To: <4382E15C.5070206@archonet.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0 required=5 tests=[AWL=0.000] X-Spam-Score: 0 X-Spam-Level: X-Archive-Number: 200511/189 X-Sequence-Number: 23440 Richard Huxton wrote: > george young wrote: > >> Well, I don't have any need for it to correlate with the age of the >> tuple. My use of step.ctid> latest row, but just to *choose* one. Perhaps there's some other >> query that would modify only one of each pair of equal-keyed rows? > > > How do you know there is only 1 duplicate? > > Anyway, if (x,y) are the same but (z) is not then you can compare > against max(z) or min(z). Something like: > > SELECT t1.x AS update_me_x, t1.y AS update_me_y, t1.z AS update_me_z > FROM > test_tbl AS t1, > ( > SELECT x,y,max(z) AS max_z > FROM test_tbl > GROUP BY x,y > ) AS t2 > WHERE > t1.x = t2.x AND t1.y = t2.y AND t1.z = t2.max_z Oh, of course the easiest way to do it is to add an additional column of type SERIAL to your temp-table. That way you have your rows nicely numbered as you import them. -- Richard Huxton Archonet Ltd