From: mike@if-then-else.pl
To: grandebuzon@gmail.com
Cc: pgsql-sql@postgresql.org
Subject: Re: The best option to insert data with primary id
Date: Mon, 06 Dec 2010 17:21:31 +0100
Message-ID: <20101206172131.cjlul2oggc0848so@horde.iq.pl> (raw)
In-Reply-To: <AANLkTin07UawZyr1xQM4nfUQaBrG0FbwS2N=q-zRiwKB@mail.gmail.com>
References: <AANLkTint7hvf03OXc8ujqWE+a2ETWUXu7NtHysKqZjUG@mail.gmail.com>
<20101206162725.o3q9xfug2ioo08g8@horde.iq.pl>
<AANLkTin07UawZyr1xQM4nfUQaBrG0FbwS2N=q-zRiwKB@mail.gmail.com>
Quoting - <grandebuzon@gmail.com>:
> I know you can skip SEQUENCE - ((SELECT nextval ('seq_table')) do not put
> this in the query, my question was that such concurrency, and ids
> omitted which can not be inserted but increased with SEQUENCE ?
In the initial message you have been wondering, if you should be worried
about "wasted" sequence tokens. You have mentioned, that your primary key
is of type int8 and so is the sequence range. Do you really expect as many
records and/or insert queries?
If so, consider the id column int8 DEFAULT NULL and an AFTER INSERT trigger
function that would take a nextval of the sequence and update the id
accordingly once the record *has been actually inserted* instead of poking
the sequence each time you *are going to insert* something.
I am pretty sure, that the table is locked to prevent inserts until the
after-insert-trigger is finished.
Cheers,
-Mike
--
MichaĆ Roszka
mike@if-then-else.pl
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: mike@if-then-else.pl, grandebuzon@gmail.com
Subject: Re: The best option to insert data with primary id
In-Reply-To: <20101206172131.cjlul2oggc0848so@horde.iq.pl>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox