Re: pg_dump restore time and Foreign Keys

From: Simon Riggs <simon(at)2ndquadrant(dot)com>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Decibel! <decibel(at)decibel(dot)org>, Robert Treat <xzilla(at)users(dot)sourceforge(dot)net>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: pg_dump restore time and Foreign Keys
Date: 2008-06-09 15:46:19
Message-ID: 1213026379.12046.119.camel@ebony.site
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


On Mon, 2008-06-09 at 11:23 -0400, Andrew Dunstan wrote:
>
> Simon Riggs wrote:
> > On Mon, 2008-06-09 at 10:57 -0400, Tom Lane wrote:
> >
> >> Decibel! <decibel(at)decibel(dot)org> writes:
> >>
> >>> Actually, in the interest of stating the problem and not the
> >>> solution, what we need is a way to add FKs that doesn't lock
> >>> everything up to perform the key checks.
> >>>
> >> Ah, finally a useful comment. I think it might be possible to do an
> >> "add FK concurrently" type of command that would take exclusive lock
> >> for just long enough to add the triggers, then scan the tables with just
> >> AccessShareLock to see if the existing rows meet the constraint, and
> >> if so finally mark the constraint "valid". Meanwhile the constraint
> >> would be enforced against newly-added rows by the triggers, so nothing
> >> gets missed. You'd still get a small hiccup in system performance
> >> from the transient exclusive lock, but nothing like as bad as it is
> >> now. Would that solve your problem?
> >>
> >
> > That's good, but it doesn't solve the original user complaint about
> > needing to re-run many, many large queries to which we already know the
> > answer.
> >
> But we don't know it for dead sure, we only think we do. What if the
> data for one or other of the tables is corrupted? We'll end up with data
> we believe is consistent but in fact is not, ISTM. If you can somehow
> guarantee the integrity of data in both tables then we might be
> justified in assuming that the FK constraint will be consistent - that's
> why I suggested some sort of checksum mechanism might serve the purpose.

Agreed.

Can we get COPY to output the checksum of its output as part of the
command tag? How else can we return the checksum? In $file.cksum for any
given output file?

We can then use an explicit checksum option in the COPY when we reload,
with CHECKSUM option.

--
Simon Riggs www.2ndQuadrant.com
PostgreSQL Training, Services and Support

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Simon Riggs 2008-06-09 15:48:05 Re: pg_dump restore time and Foreign Keys
Previous Message Tom Lane 2008-06-09 15:33:19 Re: pg_dump restore time and Foreign Keys