Re: ORDER BY random() LIMIT 1 slowness

From: Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl>
To: Jean-Luc Lachance <jllachan(at)nsd(dot)ca>
Cc: SZUCS Gábor <surrano(at)mailbox(dot)hu>, pgsql-general(at)postgresql(dot)org
Subject: Re: ORDER BY random() LIMIT 1 slowness
Date: 2002-12-18 19:23:55
Message-ID: 20021218192355.GN2800@dcc.uchile.cl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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)

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Joe Conway 2002-12-18 19:35:11 Re: Measuring CPU time use? (Another stupid question)
Previous Message George.T.Essig 2002-12-18 19:16:58 Re: Table Timemachine!