Re: slow query execution

From: Rodrigo De León <rdeleonp(at)gmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org, "Trigve Siver" <trigves(at)yahoo(dot)com>
Subject: Re: slow query execution
Date: 2007-05-30 17:28:47
Message-ID: a55915760705301028r69887f67q2efcb814550b80c5@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On 5/30/07, Trigve Siver <trigves(at)yahoo(dot)com> wrote:
> Can you point me to some sources
> or give me some examples, please?

CREATE OR REPLACE FUNCTION ROWNUM() RETURNS BIGINT AS
$$
BEGIN
RETURN NEXTVAL('ROWNUM_SEQ');
EXCEPTION WHEN OTHERS THEN
CREATE TEMP SEQUENCE ROWNUM_SEQ;
RETURN NEXTVAL('ROWNUM_SEQ');
END;
$$
LANGUAGE 'PLPGSQL';

SELECT ROWNUM(), S.X
FROM GENERATE_SERIES(5,1,-1) S(X);

Remember to reset the sequence value if you use this more than once in
the same session.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Trigve Siver 2007-05-30 17:30:56 Re: slow query execution
Previous Message Trigve Siver 2007-05-30 17:03:16 Re: slow query execution