From: | Jeff Frost <jeff(at)frostconsultingllc(dot)com> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | Why does the sequence skip a number with generate_series? |
Date: | 2007-10-03 00:20:08 |
Message-ID: | Pine.LNX.4.64.0710021716490.4701@discord.home.frostconsultingllc.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers pgsql-sql |
I expected these numbers to be in sync, but was suprised to see that the
sequence skips a values after every generate series.
CREATE TABLE jefftest ( id serial, num int );
INSERT INTO jefftest (num) values (generate_series(1,10));
INSERT INTO jefftest (num) values (generate_series(11,20));
INSERT INTO jefftest (num) values (generate_series(21,30));
id | num
----+-----
1 | 1
2 | 2
3 | 3
4 | 4
5 | 5
6 | 6
7 | 7
8 | 8
9 | 9
10 | 10
12 | 11
13 | 12
14 | 13
15 | 14
16 | 15
17 | 16
18 | 17
19 | 18
20 | 19
21 | 20
23 | 21
24 | 22
25 | 23
26 | 24
27 | 25
28 | 26
29 | 27
30 | 28
31 | 29
32 | 30
But, if I just use single inserts, the sequence increments by one like I
expect:
jefftest=# INSERT INTO jefftest (num) VALUES (1);
INSERT 0 1
jefftest=# INSERT INTO jefftest (num) VALUES (2);
INSERT 0 1
jefftest=# INSERT INTO jefftest (num) VALUES (3);
INSERT 0 1
jefftest=# INSERT INTO jefftest (num) VALUES (4);
INSERT 0 1
jefftest=# INSERT INTO jefftest (num) VALUES (5);
INSERT 0 1
jefftest=# select * from jefftest;
id | num
----+-----
1 | 1
2 | 2
3 | 3
4 | 4
5 | 5
(5 rows)
Obviously, this doesn't hurt anything, I'm just curious why it skips one after
every generate_series insert?
--
Jeff Frost, Owner <jeff(at)frostconsultingllc(dot)com>
Frost Consulting, LLC http://www.frostconsultingllc.com/
Phone: 650-780-7908 FAX: 650-649-1954
From | Date | Subject | |
---|---|---|---|
Next Message | Alvaro Herrera | 2007-10-03 01:07:54 | Re: Re: [COMMITTERS] pgsql: Fix free space map to correctly track the total amount of FSM |
Previous Message | Decibel! | 2007-10-03 00:17:39 | Re: [HACKERS] Re: pgsql: Fix free space map to correctly track the total amount of FSM |
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2007-10-03 03:48:09 | Re: Finding broken regex'es |
Previous Message | Erik Jones | 2007-10-02 21:36:55 | Re: Finding broken regex'es |