Re: single transaction vs multiple transactions

From: "Heikki Linnakangas" <heikki(at)enterprisedb(dot)com>
To: "Sven Geisler" <sgeisler(at)aeccom(dot)com>
Cc: <pgsql-performance(at)postgresql(dot)org>
Subject: Re: single transaction vs multiple transactions
Date: 2006-12-05 15:42:57
Message-ID: 45759381.40909@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Sven Geisler wrote:
> I have to insert my arguments to a temporary table first, because the
> arguments are only known in the application tier.
> Is a multiple insert to a temporary table and a final 'DELETE FROM x
> WHERE y IN (SELECT z FROM tmp)' faster than multiple deletes?

If the number of records is high, it most likely is faster. You should
try it with your data to be sure, but in general doing all the deletes
in one batch is faster when the number of records is high because it
allows using efficient merge joins or sequential scans.

Populating the temporary table with no indexes should be quite
inexpensive if you make sure you don't do it one record at a time. Use
the COPY command or batched inserts instead.

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Jens Schipkowski 2006-12-05 15:45:25 Re: single transaction vs multiple transactions
Previous Message Sven Geisler 2006-12-05 15:35:19 Re: single transaction vs multiple transactions