Search Postgresql Archives

Re: Is it necessary to have index for child table in following case?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> 
> 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 :)


      


-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux