Re: INSERT... WHERE

From: Serge Fonville <serge(dot)fonville(at)gmail(dot)com>
To: Darren Duncan <darren(at)darrenduncan(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: INSERT... WHERE
Date: 2013-01-15 09:15:44
Message-ID: CAOAS_++genXVjQjRSH8MGohxMwLGJZ25FaRrpCc69cpmiOoYcw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

Based on my understanding of the problem, would this be possible to solve
with a MERGE statement?

HTH

Kind regards/met vriendelijke groet,

Serge Fonville

http://www.sergefonville.nl

Convince Microsoft!
They need to add TRUNCATE PARTITION in SQL Server
https://connect.microsoft.com/SQLServer/feedback/details/417926/truncate-partition-of-partitioned-table

2013/1/15 Darren Duncan <darren(at)darrenduncan(dot)net>

> On 2013.01.13 6:00 PM, Robert James wrote:
>
>> I have a lot of VALUES I want to INSERT. But only a subset of them -
>> only those that meet a JOIN criteria involving another table.
>>
>> I could INSERT them into a temp table, and then do a SELECT INTO. But
>> do I need to do that? Is there any way to do a INSERT... VALUES ...
>> WHERE...
>>
>
> As per my reply to your "Bulk INSERT with individual failure" thread, for
> what you want to do a temporary staging table (or several) with minimal
> constraints is truly your best option to accomplish your goal.
>
> Having a large amount of literals in an INSERT statement like discussed is
> a bad idea.
>
> If you're loading from a file, just use some bulk load feature that
> bypasses the need for INSERT statements, into some temp file matching the
> format of the file.
>
> If you're loading from a program, use a prepared single-row INSERT
> statement, bundling batches of say a few thousand rows at a time into a
> single transaction.
>
> Then pretend your newly populated temp table was your original source, but
> now it is visible to SQL, and you can load your regular tables from the
> temp table(s) much more nicely.
>
> -- Darren Duncan
>
>
>
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/**mailpref/pgsql-general<http://www.postgresql.org/mailpref/pgsql-general>
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Serge Fonville 2013-01-15 09:19:53 Re: INSERT... WHERE
Previous Message T. E. Lawrence 2013-01-15 08:36:59 Re: reducing number of ANDs speeds up query RESOLVED