RE: Load data from a csv file without using COPY

Поиск
Список
Период
Сортировка
От Kevin Brannen
Тема RE: Load data from a csv file without using COPY
Дата
Msg-id SN1PR19MB0255115CC3B9EA3B3384FB25A44A0@SN1PR19MB0255.namprd19.prod.outlook.com
обсуждение исходный текст
Ответ на Re: Load data from a csv file without using COPY  (Ravi Krishna <srkrishna@yahoo.com>)
Ответы Re: Load data from a csv file without using COPY
Список pgsql-general
From: Ravi Krishna [mailto:srkrishna@yahoo.com]
Sent: Tuesday, June 19, 2018 4:15 PM
To: Steve Atkins <steve@blighty.com>
Cc: PG mailing List <pgsql-general@lists.postgresql.org>
Subject: Re: Load data from a csv file without using COPY

>
> If performance is relevant then your app should probably be using COPY
> protocol, not line by line inserts. It's supported by most postgresql
> access libraries. If your app does that then using "\copy" from psql would be an appropriate benchmark.

Actually the reluctance to not use COPY is to make the benchmark same across two different RDBMS in two diff env.

---

Seems like a ~10 line Perl program could handle this very easily. Use the Text::CSV module to make handling of the
inputeasier. Prepare your insert statement, then once you've pulled each line of input in execute the insert. For
slightlybetter performance, I'd probably use transactions, add a counter, and commit every 10,000 rows (or something
likethat). 

Once you have that working with 1 DB, you can copy your program, change the DBD driver and the connect statement to the
otherDB and try the other one. Unless you want to be really clever and make the same program do both and pick the DB by
acommand line switch. :) 

HTH,
Kevin
This e-mail transmission, and any documents, files or previous e-mail messages attached to it, may contain confidential
information.If you are not the intended recipient, or a person responsible for delivering it to the intended recipient,
youare hereby notified that any disclosure, distribution, review, copy or use of any of the information contained in or
attachedto this message is STRICTLY PROHIBITED. If you have received this transmission in error, please immediately
notifyus by reply e-mail, and destroy the original transmission and its attachments without reading them or saving them
todisk. Thank you. 


В списке pgsql-general по дате отправления:

Предыдущее
От: Anto Aravinth
Дата:
Сообщение: Re: Using COPY to import large xml file
Следующее
От: Nicolas Paris
Дата:
Сообщение: Re: Using COPY to import large xml file