Why does the sequence skip a number with generate_series? - Mailing list pgsql-sql

From Jeff Frost
Subject Why does the sequence skip a number with generate_series?
Date
Msg-id Pine.LNX.4.64.0710021716490.4701@discord.home.frostconsultingllc.com
Whole thread Raw
Responses Re: Why does the sequence skip a number with generate_series?
List 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@frostconsultingllc.com>
Frost Consulting, LLC     http://www.frostconsultingllc.com/
Phone: 650-780-7908    FAX: 650-649-1954


pgsql-sql by date:

Previous
From: "Tena Sakai"
Date:
Subject: field separator problem
Next
From: Michael Fuhr
Date:
Subject: Re: field separator problem