pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Thomas F.O'Connell <tfo@sitening.com>
To: josh@agliodbs.com
Cc: PgSQL - Performance <pgsql-performance@postgresql.org>
Subject: Re: Triggers During COPY
Date: Fri, 28 Jan 2005 11:17:23 -0600
Message-ID: <a8db069c1646fcd04ce386895fea3735@sitening.com> (raw)
In-Reply-To: <200501272141.49531.josh@agliodbs.com>
References: <f2a4e35d83b33da9b5d007d276df484a@sitening.com>
	<200501272141.49531.josh@agliodbs.com>

As far as dropping/recreating triggers, there seem to be two strategies:

1. Perform the drop-import-create operation in a transaction, thereby 
guaranteeing the accuracy of the counts but presumably locking the 
table during the operation, which could take many minutes (up to an 
hour or two) in extreme cases.

2. Drop the triggers, import, create the triggers, and update with the 
import count, recognizing that other updates could've occurred without 
accumulating updates during the import process, then later (nightly, 
maybe?) do a full update to recalibrate the counts. In this case the 
count( * ) involved could also lock the table for a bit pending the 
sequential scan(s) if the update is performed in a transaction. 
Otherwise, again, there is a realistic possibility of inaccurate counts 
occurring and persisting between calibrations.

Is there a best practice anywhere here?

-tfo

--
Thomas F. O'Connell
Co-Founder, Information Architect
Sitening, LLC
http://www.sitening.com/
110 30th Avenue North, Suite 6
Nashville, TN 37203-6320
615-260-0005

On Jan 27, 2005, at 11:41 PM, Josh Berkus wrote:

> Thomas,
>
>> Would it be absurd to drop the triggers during import and recreate 
>> them
>> afterward and update the counts in a summ> ary update based on
>> information from the import process?
>
> That's what I'd do.
>
> -- 
> --Josh
>
> Josh Berkus
> Aglio Database Solutions
> San Francisco




view thread (6+ messages)  latest in thread

Message-ID: <a8db069c1646fcd04ce386895fea3735@sitening.com>
Permalink:  ../a8db069c1646fcd04ce386895fea3735@sitening.com/
Also on:    postgresql.org/message-id/a8db069c1646fcd04ce386895fea3735@sitening.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: tfo@sitening.com, josh@agliodbs.com
  Subject: Re: Triggers During COPY
  In-Reply-To: <a8db069c1646fcd04ce386895fea3735@sitening.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox