dbTalk Databases Forums  

INSERT or COPY: Which one?

comp.databases.postgresql.novice comp.databases.postgresql.novice


Discuss INSERT or COPY: Which one? in the comp.databases.postgresql.novice forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Colin Gillespie
 
Posts: n/a

Default INSERT or COPY: Which one? - 02-16-2004 , 04:13 AM






Dear All,

I which to insert text (more than 1000 lines) into a single cell of my table, should I use COPY here or INSERT?

My reading seems to suggest that you would use COPY for mulitple INSERTs, but when inserting alot of data into one cell, INSERT is fine. Is this correct?

Thanks

Colin



---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster


Reply With Quote
  #2  
Old   
Nabil Sayegh
 
Posts: n/a

Default Re: INSERT or COPY: Which one? - 02-17-2004 , 02:01 PM






Colin Gillespie wrote:
Quote:
Dear All,

I which to insert text (more than 1000 lines) into a single cell of my table, should I use COPY here or INSERT?

My reading seems to suggest that you would use COPY for mulitple INSERTs, but when inserting alot of data into one cell, INSERT is fine. Is this correct?
COPY is much faster, INSERT is safer.
I heard that all issues regarding COPY are fixed (since 7.3?), but IIRC I still had some trouble
with SERIALs and referential integrity.

HTH
--
e-Trolley Sayegh & John, Nabil Sayegh
Tel.: 0700 etrolley /// 0700 38765539
Fax.: +49 69 8299381-8
PGP : http://www.e-trolley.de

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend



Reply With Quote
  #3  
Old   
Wim
 
Posts: n/a

Default Re: INSERT or COPY: Which one? - 02-18-2004 , 01:58 AM



Hi Colin,

COPY is much faster that INSERT, although INSERT is safer. I think that
you can speed up the INSERT by disabling autocommit...


Cheers!
Wim

On Mon, 16 Feb 2004, Colin Gillespie wrote:

Quote:
Dear All,

I which to insert text (more than 1000 lines) into a single cell of my table, should I use COPY here or INSERT?

My reading seems to suggest that you would use COPY for mulitple INSERTs, but when inserting alot of data into one cell, INSERT is fine. Is this correct?

Thanks

Colin



---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

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



Reply With Quote
  #4  
Old   
Bryan Irvine
 
Posts: n/a

Default Re: INSERT or COPY: Which one? - 06-03-2004 , 03:23 PM



I got this today and I don't know the if the list is behind or the
senders client, so I'll reply anyway.

I did some benchmark testing of copy vs insert, using a 3 million record
file with 1 table and 3 fields containing 10 numbers (between all
fields, they were phonenumbers to be precise). The insert took about 2
hours (this was last summer so my numbers might be slightly off) and the
copy took 45 seconds.

So use copy when appropriate.

--Bryan

On Tue, 2004-02-17 at 12:01, Nabil Sayegh wrote:
Quote:
Colin Gillespie wrote:
Dear All,

I which to insert text (more than 1000 lines) into a single cell of my table, should I use COPY here or INSERT?

My reading seems to suggest that you would use COPY for mulitple INSERTs, but when inserting alot of data into one cell, INSERT is fine. Is this correct?

COPY is much faster, INSERT is safer.
I heard that all issues regarding COPY are fixed (since 7.3?), but IIRC I still had some trouble
with SERIALs and referential integrity.

HTH

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



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.