Re: COPY data into a table with a SERIAL column?

From: Steve Wampler <swampler(at)noao(dot)edu>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: COPY data into a table with a SERIAL column?
Date: 2014-10-16 18:17:45
Message-ID: 54400BC9.2020108@noao.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 10/16/2014 10:44 AM, Rob Sargent wrote:
> On 10/16/2014 11:38 AM, David G Johnston wrote:
>> COPY is dumb but fast. If you need logic you need to add it yourself.
>> Either before the copy or copy into a temporary UNLOGGED table and write
>> smart SQL to migrate from that to the live table.
>>
>> You can also put smarts into a trigger.

Never thought about a trigger on a COPY before. I'll look into that and
see what the hit is.

I was kinda hoping there was the equivalent of \N for indicating the use
of a default value instead of a null value, but I accept that such a thing
might be too expensive for COPY's goal in life.

Maybe the best approach is to switch to a batched insert, which might be
fast enough for my needs.

Thanks for the suggestions!

--
Steve Wampler -- swampler(at)noao(dot)edu
The gods that smiled on your birth are now laughing out loud.

--
This mail was scanned by a trial version of BitDefender
For more information please visit http://www.bitdefender.com/

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2014-10-16 19:44:18 Re: Newb question - PostgreSQL ODBC Driver for Teiid
Previous Message Igor Neyman 2014-10-16 18:11:54 Re: Misunderstanding deadlocks