I shoul start the sequence with the last number in the higher number in the table +1.
It works.

Sterpu Victor wrote:

I have the following table
     Column       |  Type   |                            Modifiers
----------------+-------+----------------------------------------------------------------- id | integer | not null default nextval('cachedgroupmembers_id_seq'::regclass)
groupid            | integer |
memberid         | integer |
via                    | integer |
immediatepar    | integer |
disabled           | integer | not null default 0
Indexes:
   "cachedgroupmembers_pkey" PRIMARY KEY, btree (id)
   "cachedgroupmembers2" btree (memberid)
   "cachedgroupmembers3" btree (groupid)
   "disgroumem" btree (groupid, memberid, disabled)

And the sequence for the id column:
CREATE SEQUENCE cachedgroupmembers_id_seq CACHE 1000;

Now the table is empty and I try to insert a row in this table:
INSERT INTO cachedgroupmembers(groupid) values(55);
And it works.

Next I populate the table wittt aprox 700.000 records.
And I do again  "INSERT INTO cachedgroupmembers(groupid) values(55);".
The error is : ERROR: duplicate key violates unique constraint "cachedgroupmembers_pkey"

Thank you.





---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
      choose an index scan if your joining column's datatypes do not
      match

Reply via email to