Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 389C31337B6E for ; Thu, 16 Dec 2010 08:24:25 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 59724-06 for ; Thu, 16 Dec 2010 12:24:17 +0000 (UTC) Received: from news.hub.org (news.hub.org [200.46.204.72]) by mail.postgresql.org (Postfix) with ESMTP id BC2571337B68 for ; Thu, 16 Dec 2010 08:24:17 -0400 (AST) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.14.4/8.14.4) with ESMTP id oBGCOGst075813 for ; Thu, 16 Dec 2010 08:24:16 -0400 (AST) (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.14.4/8.14.4/Submit) id oBGCC3k5052519 for pgsql-performance@postgresql.org; Thu, 16 Dec 2010 08:12:03 -0400 (AST) (envelope-from news) From: Eric Comeau X-Newsgroups: pgsql.performance Subject: How to get FK to use new index without restarting the database Date: Thu, 16 Dec 2010 07:12:03 -0500 Organization: Hub.Org Networking Services Lines: 25 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@news.hub.org User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101208 Lightning/1.0b2 Thunderbird/3.1.7 To: pgsql-performance@postgresql.org X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-10 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201012/190 X-Sequence-Number: 41642 Is there a way force the db to re-evaluate its execution plan for a FK without bouncing the DB? PostgreSQL 8.1.17 In our latest release our developers have implemented some new foreign keys but forgot to create indexes on these keys. The problem surfaced at one of our client installs where a maintenance DELETE query was running for over 24 hrs. We have since then identified the missing indexes and have sent the client a script to create them, but in our testing we could not been able to get postgres to use the new index for the FK cascade delete without bouncing the database. Here is an example of an added fk but missing index.... ALTER TABLE scheduled_job_arg ADD CONSTRAINT sjr_scheduled_job_id_fk FOREIGN KEY (scheduled_job_id) REFERENCES scheduled_job (id) ON UPDATE CASCADE ON DELETE CASCADE; Thanks in Advance, Eric