From: | mike(at)if-then-else(dot)pl |
---|---|
To: | grandebuzon(at)gmail(dot)com |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: The best option to insert data with primary id |
Date: | 2010-12-06 16:21:31 |
Message-ID: | 20101206172131.cjlul2oggc0848so@horde.iq.pl |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Quoting - <grandebuzon(at)gmail(dot)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(at)if-then-else(dot)pl
From | Date | Subject | |
---|---|---|---|
Next Message | bricklen | 2010-12-06 19:39:23 | Re: Union Question |
Previous Message | mike | 2010-12-06 15:27:25 | Re: The best option to insert data with primary id |