Skip site navigation (1) Skip section navigation (2)

Re: BUG #3811: Getting multiple values from a sequence generator

From: Gregory Stark <stark(at)enterprisedb(dot)com>
To: "Adriaan van Os" <postgres(at)microbizz(dot)nl>
Cc: <pgsql-bugs(at)postgresql(dot)org>, "Michael Glaesemann" <grzm(at)seespotcode(dot)net>
Subject: Re: BUG #3811: Getting multiple values from a sequence generator
Date: 2007-12-10 11:19:14
Message-ID: 873auahk5p.fsf@oxford.xeocode.com (view raw or flat)
Thread:
Lists: pgsql-bugspgsql-hackers
"Adriaan van Os" <postgres(at)microbizz(dot)nl> writes:

> Right, I want to use it with a bulk operation, say importing a million records
> with COPY. Calling nextval one million times looks to me like an enormous waste
> of resources. Suppose, you are on an ADSL line: it will cost one million times
> the ping time of the ADSL line (say 10 milliseconds per call). Well OK, one
> could write a server function that does this, but then the one million result
> values must be transported back to the client, because they are not guaranteed
> to be contiguous. Unneeded complexity compared to a simple nextval increment
> parameter.

The usual way to use nextval() is to use it on the server as an expression in
an INSERT or DEFAULT. If you're using COPY and don't have a column default set
up then, hm, I guess you're kind of stuck. That would make a good use case for
a one-time nextval(increment) or something like that.

-- 
  Gregory Stark
  EnterpriseDB          http://www.enterprisedb.com
  Ask me about EnterpriseDB's PostGIS support!

In response to

Responses

pgsql-hackers by date

Next:From: hubert depesz lubaczewskiDate: 2007-12-10 11:31:43
Subject: Re: BUG #3811: Getting multiple values from a sequence generator
Previous:From: Peter EisentrautDate: 2007-12-10 10:50:08
Subject: Re: whats the deal with -u ?

pgsql-bugs by date

Next:From: hubert depesz lubaczewskiDate: 2007-12-10 11:31:43
Subject: Re: BUG #3811: Getting multiple values from a sequence generator
Previous:From: hubert depesz lubaczewskiDate: 2007-12-10 10:12:13
Subject: why "alter table" to change owner of sequence?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group