pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Very Urgent : Sequences Problem
6+ messages / 6 participants
[nested] [flat]

* Very Urgent : Sequences Problem
@ 2008-11-19 15:54 Kranti™ K K Parisa <kranti.parisa@gmail.com>
  2008-11-19 16:31 ` Re: [PERFORM] Very Urgent : Sequences Problem Tino Wildenhain <tino@wildenhain.de>
  2008-11-19 16:31 ` Re: [PERFORM] Very Urgent : Sequences Problem Josh Berkus <josh@agliodbs.com>
  2008-11-19 16:40 ` Re: [PERFORM] Very Urgent : Sequences Problem Merlin Moncure <mmoncure@gmail.com>
  0 siblings, 3 replies; 6+ messages in thread

From: Kranti™ K K Parisa @ 2008-11-19 15:54 UTC (permalink / raw)
  To: pgsql-admin@postgresql.org; pgsql-performance

Hi,

I have defined sequence on a table something like this


CREATE SEQUENCE items_unqid_seq
  INCREMENT 1
  MINVALUE 0
  MAXVALUE 9223372036854775807
  START 7659
  CACHE 1;

this is on a table called items. where i have currently the max(unq_id) as
7659.

and in the stored procedure when i am inserting values into the items table
for the unq_id column i am using the sequence as follows:

nextval('items_unqid_seq'::text)


it seems to be working some times. and the sequences are not getting updated
sometime. which is casuing primary key exceptions.

please advise as soon as possible.

is there any trivial problem with sequences in postgresql??

thanks in advance.

-- 
Kranti

^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: [PERFORM] Very Urgent : Sequences Problem
  2008-11-19 15:54 Very Urgent : Sequences Problem Kranti™ K K Parisa <kranti.parisa@gmail.com>
@ 2008-11-19 16:31 ` Tino Wildenhain <tino@wildenhain.de>
  2 siblings, 0 replies; 6+ messages in thread

From: Tino Wildenhain @ 2008-11-19 16:31 UTC (permalink / raw)
  To: Kranti™ K K Parisa <kranti.parisa@gmail.com>; +Cc: pgsql-admin@postgresql.org

Hi,

Kranti™ K K Parisa wrote:
> Hi,
> 
> I have defined sequence on a table something like this
> 
> 
> CREATE SEQUENCE items_unqid_seq
>   INCREMENT 1
>   MINVALUE 0
>   MAXVALUE 9223372036854775807
>   START 7659
>   CACHE 1;
> 
> this is on a table called items. where i have currently the max(unq_id) 
> as 7659.
> 
> and in the stored procedure when i am inserting values into the items 
> table for the unq_id column i am using the sequence as follows:
> 
> nextval('items_unqid_seq'::text)
> 
> 
> it seems to be working some times. and the sequences are not getting 
> updated sometime. which is casuing primary key exceptions.

Thats actually not possible. Sequences are never rolled
back. The only way would be using stale values from
your function call or some other inserts trying to
overwrite or insert into the table twice with the same
id.

> please advise as soon as possible.
> 
> is there any trivial problem with sequences in postgresql??

nope.

> thanks in advance.

This is neither admin nor performance related so you better
send such questions to psql-general.

Thank you
Tino

Attachments:

  smime.p7s (application/x-pkcs7-signature, 3.2K) download

^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: [PERFORM] Very Urgent : Sequences Problem
  2008-11-19 15:54 Very Urgent : Sequences Problem Kranti™ K K Parisa <kranti.parisa@gmail.com>
@ 2008-11-19 16:31 ` Josh Berkus <josh@agliodbs.com>
  2008-11-20 05:04   ` Re: Very Urgent : Sequences Problem Greg Smith <gsmith@gregsmith.com>
  2 siblings, 1 reply; 6+ messages in thread

From: Josh Berkus @ 2008-11-19 16:31 UTC (permalink / raw)
  To: Kranti™ K K Parisa <kranti.parisa@gmail.com>; +Cc: pgsql-admin@postgresql.org; pgsql-performance

Kranti (tm),

If you problem is very urgent, I suggest that you get a paid support 
contract with a PostgreSQL support company.  You can find a list of 
support companies here:

http://www.postgresql.org/support/professional_support

These mailing lists are made up of other PostgreSQL users and 
developers, none of whom are paid to help anyone with support issues.

Cross-posting two PostgreSQL mailing lists for a problem which is very 
urgent to you, but not to us, is a guarenteed way not to get a useful 
answer.  It suggests that you think you are more important than anyone 
else in the community.

--Josh Berkus



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Very Urgent : Sequences Problem
  2008-11-19 15:54 Very Urgent : Sequences Problem Kranti™ K K Parisa <kranti.parisa@gmail.com>
  2008-11-19 16:31 ` Re: [PERFORM] Very Urgent : Sequences Problem Josh Berkus <josh@agliodbs.com>
@ 2008-11-20 05:04   ` Greg Smith <gsmith@gregsmith.com>
  0 siblings, 0 replies; 6+ messages in thread

From: Greg Smith @ 2008-11-20 05:04 UTC (permalink / raw)
  To: ; +Cc: Krantiâ~D¢ K K Parisa <kranti.parisa@gmail.com>; pgsql-performance

On Wed, 19 Nov 2008, Josh Berkus wrote:

> Cross-posting two PostgreSQL mailing lists for a problem which is very urgent 
> to you, but not to us, is a guarenteed way not to get a useful answer.

Posting to the performance list like this, with a question that in no way 
whatsoever has anything to do with database performance, is another good 
way to get your question ignored.

--
* Greg Smith gsmith@gregsmith.com http://www.gregsmith.com Baltimore, MD



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: [PERFORM] Very Urgent : Sequences Problem
  2008-11-19 15:54 Very Urgent : Sequences Problem Kranti™ K K Parisa <kranti.parisa@gmail.com>
@ 2008-11-19 16:40 ` Merlin Moncure <mmoncure@gmail.com>
  2008-11-19 16:53   ` Re: [PERFORM] Very Urgent : Sequences Problem tv@fuzzy.cz
  2 siblings, 1 reply; 6+ messages in thread

From: Merlin Moncure @ 2008-11-19 16:40 UTC (permalink / raw)
  To: Kranti™ K K Parisa <kranti.parisa@gmail.com>; +Cc: pgsql-admin@postgresql.org; pgsql-performance

On Wed, Nov 19, 2008 at 10:54 AM, Kranti™ K K Parisa
<kranti.parisa@gmail.com> wrote:
> Hi,
>
> I have defined sequence on a table something like this
>
>
> CREATE SEQUENCE items_unqid_seq
>   INCREMENT 1
>   MINVALUE 0
>   MAXVALUE 9223372036854775807
>   START 7659
>   CACHE 1;
>
> this is on a table called items. where i have currently the max(unq_id) as
> 7659.
>
> and in the stored procedure when i am inserting values into the items table
> for the unq_id column i am using the sequence as follows:
>
> nextval('items_unqid_seq'::text)
>
>
> it seems to be working some times. and the sequences are not getting updated
> sometime. which is casuing primary key exceptions.
>
> please advise as soon as possible.
>
> is there any trivial problem with sequences in postgresql??

no (at least none that I know of).

maybe if you posted the source of your procedure?  I bet your error is
coming form some other source.

merlin



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: [PERFORM] Very Urgent : Sequences Problem
  2008-11-19 15:54 Very Urgent : Sequences Problem Kranti™ K K Parisa <kranti.parisa@gmail.com>
  2008-11-19 16:40 ` Re: [PERFORM] Very Urgent : Sequences Problem Merlin Moncure <mmoncure@gmail.com>
@ 2008-11-19 16:53   ` tv@fuzzy.cz
  0 siblings, 0 replies; 6+ messages in thread

From: tv@fuzzy.cz @ 2008-11-19 16:53 UTC (permalink / raw)
  To: Merlin Moncure <mmoncure@gmail.com>; +Cc: Kranti&#65533@sq.gransy.com, "K K Parisa" <kranti.parisa@gmail.com>; pgsql-admin@postgresql.org; pgsql-performance

> On Wed, Nov 19, 2008 at 10:54 AM, Kranti&#65533; K K Parisa
> <kranti.parisa@gmail.com> wrote:
>> Hi,
>>
>> I have defined sequence on a table something like this
>>
>>
>> CREATE SEQUENCE items_unqid_seq
>>   INCREMENT 1
>>   MINVALUE 0
>>   MAXVALUE 9223372036854775807
>>   START 7659
>>   CACHE 1;
>>
>> this is on a table called items. where i have currently the max(unq_id)
>> as
>> 7659.
>>
>> and in the stored procedure when i am inserting values into the items
>> table
>> for the unq_id column i am using the sequence as follows:
>>
>> nextval('items_unqid_seq'::text)
>>
>>
>> it seems to be working some times. and the sequences are not getting
>> updated
>> sometime. which is casuing primary key exceptions.
>>
>> please advise as soon as possible.
>>
>> is there any trivial problem with sequences in postgresql??
>
> no (at least none that I know of).
>
> maybe if you posted the source of your procedure?  I bet your error is
> coming form some other source.

Are you sure you're using the nextval() properly whenever you insert data
into the table? This usually happens when a developer does not use it
properly, i.e. he just uses a (select max(id) + 1 from ...) something like
that. One of the more creative ways of breaking sequences was calling
nextval() only for the first insert, and then adding 1 to the ID.

BTW. do you have RULEs defined on the table? Some time ago I run into a
problem with RULEs defined on the table, as all the rules are evaluated -
I've used nextval() in all the rules so it was incremented for each rule
and it was not clear which value was actually used. So it was not sure
which value to use in a following insert (as a FK value).

regards
Tomas




^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2008-11-20 05:04 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2008-11-19 15:54 Very Urgent : Sequences Problem Kranti™ K K Parisa <kranti.parisa@gmail.com>
2008-11-19 16:31 ` Tino Wildenhain <tino@wildenhain.de>
2008-11-19 16:31 ` Josh Berkus <josh@agliodbs.com>
2008-11-20 05:04   ` Greg Smith <gsmith@gregsmith.com>
2008-11-19 16:40 ` Merlin Moncure <mmoncure@gmail.com>
2008-11-19 16:53   ` tv@fuzzy.cz

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