Re: Primary Key Increment Doesn't Seem Correct Under Table Partition

From: Yan Cheng Cheok <yccheok(at)yahoo(dot)com>
To: Alban Hertroys <dalroi(at)solfertje(dot)student(dot)utwente(dot)nl>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Primary Key Increment Doesn't Seem Correct Under Table Partition
Date: 2010-01-27 01:00:22
Message-ID: 520799.39749.qm@web65701.mail.ac4.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


Thanks and Regards
Yan Cheng CHEOK

--- On Tue, 1/26/10, Alban Hertroys <dalroi(at)solfertje(dot)student(dot)utwente(dot)nl> wrote:

> From: Alban Hertroys <dalroi(at)solfertje(dot)student(dot)utwente(dot)nl>
> Subject: Re: [GENERAL] Primary Key Increment Doesn't Seem Correct Under Table Partition
> To: "Yan Cheng Cheok" <yccheok(at)yahoo(dot)com>
> Cc: pgsql-general(at)postgresql(dot)org
> Date: Tuesday, January 26, 2010, 6:36 PM
> On 26 Jan 2010, at 11:00, Yan Cheng
> Cheok wrote:
>
> > However, whenever I insert row into measurement table,
> I realize its primary key value is going from 2, 4, 6, 8,
> 10...
> >
> > May I know how can I prevent this?
>
> Apparently nextval on that sequence gets called multiple
> times in your queries.
>

Do you have any idea why it happens so?

> > Also, is it necessary to create index for
> measurement_id found in measurement's child table? I am
> concern on the read speed.
>
>
> Serials don't create indexes, only a sequence. Primary keys
> create indexes (to guarantee uniqueness) - foreign keys do
> not.
> So yes, you want an index on that column in the child
> table.
>

But...

measurement table does contains

CONSTRAINT pk_measurement_id PRIMARY KEY (measurement_id),

when measurement_0 child table inherits from measurement table, isn't it will inherit PRIMARY KEY (measurement_id)?

Do I still have to create index for measurement_0.measurement_id ?

> Alban Hertroys
>
> --
> Screwing up is the best way to attach something to the
> ceiling.
>
>
> !DSPAM:737,4b5ec59910605107914066!
>
>
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Pierre Chevalier 2010-01-27 01:12:18 Re: dynamic crosstab
Previous Message Greg Smith 2010-01-27 01:00:18 Re: back out configure options