Re: ORDER BY random() LIMIT 1 slowness - Mailing list pgsql-general

From Jean-Luc Lachance
Subject Re: ORDER BY random() LIMIT 1 slowness
Date
Msg-id 3E00CE39.3CFF7C51@nsd.ca
Whole thread Raw
In response to ORDER BY random() LIMIT 1 slowness  ("Gavin M. Roy" <gmr@justsportsusa.com>)
Responses Re: ORDER BY random() LIMIT 1 slowness
List pgsql-general
Alvara,

But instead of returning an error, currval() should return last_value if
nextval() was not called (with all the caveat of couse).  I think it
would be more usefull that way.

JLL


Alvaro Herrera wrote:
>
> On Wed, Dec 18, 2002 at 02:09:42PM -0500, Jean-Luc Lachance wrote:
> > OK Gabor,
> >
> > I'm the one who misunderstood.
> >
> > To me, it seem to be a bug (or at least a mis-feature) that one cannot
> > call currval() before calling nextval().
> >
> > Does anyone know why it should be like this?
>
> It doesn't make sense to call currval() if you haven't called nextval()
> before.  The meaning of currval() is "the value that was last assigned
> to you".  If you haven't called nextval(), there isn't a value assigned
> to you.
>
> If you want to know what was the last value the sequence gave to anyway,
> SELECT last_value FROM sequence.  But be aware that this is
> non-transaction safe, non-isolatable, non-anything.
>
> --
> Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
> "Entristecido, Wutra
> echa a Freyr a rodar
> y a nosotros al mar" (cancion de Las Barreras)

pgsql-general by date:

Previous
From: George.T.Essig@stls.frb.org
Date:
Subject: Re: Table Timemachine!
Next
From: Joe Conway
Date:
Subject: Re: Measuring CPU time use? (Another stupid question)