Re: Can I getting a unique ID from a select

From: "Timasmith" <timasmith(at)hotmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Can I getting a unique ID from a select
Date: 2007-03-06 01:07:25
Message-ID: 1173143245.665762.160050@p10g2000cwp.googlegroups.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mar 5, 3:35 am, b(dot)(dot)(dot)(at)wolff(dot)to (Bruno Wolff III) wrote:
> On Sat, Mar 03, 2007 at 16:46:45 -0800,
> Timasmith<timasm(dot)(dot)(dot)(at)hotmail(dot)com> wrote:
>
> > On Mar 3, 7:12 pm, b(dot)(dot)(dot)(at)wolff(dot)to (Bruno Wolff III) wrote:
> > > On Thu, Mar 01, 2007 at 06:16:02 -0800,
> > > Timasmith<timasm(dot)(dot)(dot)(at)hotmail(dot)com> wrote:
>
> > > > create view myview as
> > > > select rownum, t1.field, t2.field
> > > > from tableOne t1, tableTwo t2
> > > > where t1.key = t2.fkey
>
> > Never heard of a 'join key' but that sounds very promising. How do I
> > select it?
>
> The join key would be t1.key or t2.fkey from your example. However there
> may be multiple rows returned with the same value depending on what you
> are joining. If that is the case you, should be able to use the primary
> keys of the underlying tables to make a new candidate key for the joined
> rows.
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: explain analyze is your friend

Multiple rows with the same key renders Hibernate useless as it caches
the 'row object' and then returns the first row every time for that
object.

I think the sequence will work though, in reflection I guess it would
as fast as pulling another field, and with the numbers would be a very
long time before getting duplicates - even if you had thousands of
users, returning 100s of rows every few minutes (I think...).

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Yumiko Izumi 2007-03-06 02:51:51 pq_flush: send() failed: Broken pipe
Previous Message Andrew Hammond 2007-03-06 01:07:03 RFC tool to support development / operations work with slony replicated databases