Re: LONG delete with LOTS of FK's - Mailing list pgsql-general

From Tom Lane
Subject Re: LONG delete with LOTS of FK's
Date
Msg-id 4873.1368195293@sss.pgh.pa.us
Whole thread Raw
In response to Re: LONG delete with LOTS of FK's  (Larry Rosenman <ler@lerctr.org>)
Responses Re: LONG delete with LOTS of FK's
List pgsql-general
Larry Rosenman <ler@lerctr.org> writes:
> Any ideas on how to figure out if we ARE getting seqscan check plans,
> and better fix it?

Try an EXPLAIN ANALYZE VERBOSE on something that just deletes one row,
and wait however long it takes.  The printout should show how much time
is taken in the implementation trigger for each foreign key.  That will
at least nail down which table(s) are causing problems.

A different line of thought is that the EXPLAIN I suggested in
<25119.1367507317@sss.pgh.pa.us> isn't an entirely accurate
representation of what a foreign-key checking query is like, because the
check queries are parameterized.  You might need to do this instead:

prepare foo(referenced_column_data_type) as
  select 1 from <referencing_table> where referencing_column = $1;
explain execute foo(sample_value);

and verify you get a cheap plan for each referencing table.

            regards, tom lane


pgsql-general by date:

Previous
From: Matt Brock
Date:
Subject: Deploying PostgreSQL on CentOS with SSD and Hardware RAID
Next
From: Merlin Moncure
Date:
Subject: Re: Deploying PostgreSQL on CentOS with SSD and Hardware RAID