pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Richard Huxton <dev@archonet.com>
To: Richard Huxton <dev@archonet.com>
Cc: gry@ll.mit.edu
Cc: pgsql-sql@postgresql.org
Subject: Re: tid_le comparison for tuple id (ctid) values?
Date: Tue, 22 Nov 2005 09:29:06 +0000
Message-ID: <4382E4E2.2050601@archonet.com> (raw)
In-Reply-To: <4382E15C.5070206@archonet.com>
References: <20051121160016.282c66c2.gry@ll.mit.edu>
	<4271.1132607968@sss.pgh.pa.us>
	<20051121203527.5378122b.gry@ll.mit.edu>
	<4382E15C.5070206@archonet.com>

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<s.ctid was not to get the earliest or
>> 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



view thread (5+ messages)

Message-ID: <4382E4E2.2050601@archonet.com>
Permalink:  ../4382E4E2.2050601@archonet.com/
Also on:    postgresql.org/message-id/4382E4E2.2050601@archonet.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: dev@archonet.com, gry@ll.mit.edu
  Subject: Re: tid_le comparison for tuple id (ctid) values?
  In-Reply-To: <4382E4E2.2050601@archonet.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox