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: Is it necessary to have index for child table in following case? |
Date: | 2010-02-04 01:02:09 |
Message-ID: | 953543.49640.qm@web65713.mail.ac4.yahoo.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
>
> Are you using INSERT or COPY to insert your data? COPY
> tends to be a lot faster than separate INSERTs, especially
> if you don't wrap the INSERTs in a transaction block and
> COMMIT them in batches.
>
But I do not use File or Stdio. The data is coming in row by row real-time. I need to insert the data programmatic real-time into the database. That's why I use INSERT. But maybe I miss out something on the usage of COPY, please advice :)
> As an aside, I hope you do realise that your primary key
> isn't guaranteed to be unique across your child tables? The
> reason is the same one that you already quoted for indexes
> spanning multiple tables - a primary key is implemented
> using a unique index after all.
>
> If that matters, what you can do is make your primary key a
> foreign key to a new table with just the primary key column
> in it. Make sure you always insert a record in the primary
> key table along with the one referencing it, so that you
> will get a unique violation when you try to insert a record
> for which the primary key already exists. This will of
> course slow things down some, but if it's necessary that's
> the price to pay.
>
Oh. I didn't notice that. Thanks for pointing out. Luckily, thanks God. It doesn't matter much at this moment :)
From | Date | Subject | |
---|---|---|---|
Next Message | Adrian Klaver | 2010-02-04 01:02:39 | Re: Need to Remove Constraint, but Don't Know How - Previous attempts failed |
Previous Message | Wang, Mary Y | 2010-02-04 00:57:09 | Need to Remove Constraint, but Don't Know How - Previous attempts failed |