Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id E39B42E0144 for ; Mon, 25 Feb 2008 21:27:07 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 13724-01-2 for ; Mon, 25 Feb 2008 21:27:05 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id DF2722E0082 for ; Mon, 25 Feb 2008 21:25:14 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id m1Q1PASl019946; Mon, 25 Feb 2008 20:25:10 -0500 (EST) To: Andrew Lazarus cc: pgsql-performance@postgresql.org Subject: Re: when is a DELETE FK trigger planned? In-reply-to: <010161370.20080225125626@pillette.com> References: <010161370.20080225125626@pillette.com> Comments: In-reply-to Andrew Lazarus message dated "Mon, 25 Feb 2008 12:56:26 -0800" Date: Mon, 25 Feb 2008 20:25:10 -0500 Message-ID: <19945.1203989110@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200802/337 X-Sequence-Number: 28879 Andrew Lazarus writes: > I have a cascading delete trigger that is obviously using a seqscan. > (Explain analyze shows that trigger as taking over 1000s while all > other triggers are <1s. The value in test delete didn't even appear in > this child table, so an index scan would have been almost instant.) > If I do > DELETE FROM child_table WHERE fkey = value; > I get an index scan. Why doesn't the trigger do that, and how can I > force it to re-plan? That would depend on what PG version you're using. However, starting a fresh connection should get you a new trigger function plan in any case. regards, tom lane