Re: Get block of N numbers from sequence

From: Thomas Guettler <hv(at)tbz-pariv(dot)de>
To: Boszormenyi Zoltan <zb(at)cybertec(dot)at>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Get block of N numbers from sequence
Date: 2009-05-20 06:53:55
Message-ID: 4A13A903.4070907@tbz-pariv.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Boszormenyi Zoltan schrieb:
> Thomas Guettler írta:
>> Hi,
>>
>> how can you get N numbers (without holes) from a sequence?

> # create sequence tmp_seq cache 1000;

Hi,

"alter SEQUENCE ... cache 100" survives a rollback. That's something I like to avoid:

foo_esg_modw=# select * from foo_isu_isu_id_seq; begin; alter SEQUENCE foo_isu_isu_id_seq cache 100; rollback; select *
from foo_isu_isu_id_seq;
sequence_name | last_value | increment_by | max_value | min_value | cache_value | log_cnt |
is_cycled | is_called
------------------------+------------+--------------+---------------------+-----------+-------------+---------+-----------+-----------
foo_isu_isu_id_seq | 90508740 | 1 | 9223372036854775807 | 1 | 1 | 6 | f | t

BEGIN
ALTER SEQUENCE
ROLLBACK
sequence_name | last_value | increment_by | max_value | min_value | cache_value | log_cnt |
is_cycled | is_called
------------------------+------------+--------------+---------------------+-----------+-------------+---------+-----------+-----------
foo_isu_isu_id_seq | 90508740 | 1 | 9223372036854775807 | 1 | 100 | 6 | f | t

--
Thomas Guettler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Thomas Guettler 2009-05-20 07:00:07 Re: Get block of N numbers from sequence
Previous Message Scott Bailey 2009-05-20 06:42:27 Re: INTERVAL SECOND limited to 59 seconds?