Re: Can I getting a unique ID from a select - Mailing list pgsql-general

From Bruno Wolff III
Subject Re: Can I getting a unique ID from a select
Date
Msg-id 20070307034826.GA20089@wolff.to
Whole thread Raw
In response to Re: Can I getting a unique ID from a select  ("Timasmith" <timasmith@hotmail.com>)
List pgsql-general
On Mon, Mar 05, 2007 at 17:07:25 -0800,
  Timasmith <timasmith@hotmail.com> wrote:
> >
> > > > > create view myview as
> > > > > select rownum, t1.field, t2.field
> > > > > from tableOne t1, tableTwo t2
> > > > > where t1.key = t2.fkey
>
> 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...).

Based on the naming (t1.key vs t2.fkey) it looks like you may have a one
to many relationship. If so, can't you just bring in the primary key from
t2, as under the above assumption there will be only one matching row
from t1?

pgsql-general by date:

Previous
From: "Reuven M. Lerner"
Date:
Subject: Re: Database slowness -- my design, hardware, or both?
Next
From: Martijn van Oosterhout
Date:
Subject: Re: No buffer space available