Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1ZtGNs-0004d1-6J for pgsql-performance@arkaria.postgresql.org; Mon, 02 Nov 2015 14:46:56 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1ZtGNq-0006qR-6k for pgsql-performance@arkaria.postgresql.org; Mon, 02 Nov 2015 14:46:54 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1ZtGMB-0004Za-B7 for pgsql-performance@postgresql.org; Mon, 02 Nov 2015 14:45:11 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1ZtGM9-0002OA-4H for pgsql-performance@postgresql.org; Mon, 02 Nov 2015 14:45:10 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id tA2Ej5Z8024308; Mon, 2 Nov 2015 09:45:05 -0500 From: Tom Lane To: Guido Niewerth cc: "pgsql-performance@postgresql.org" Subject: Re: Slow query in trigger function In-reply-to: References: Comments: In-reply-to Guido Niewerth message dated "Mon, 02 Nov 2015 10:15:35 +0000" Date: Mon, 02 Nov 2015 09:45:05 -0500 Message-ID: <24307.1446475505@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org Guido Niewerth writes: > As you can see there´s a huge runtime difference between the select query used in the trigger function and the one run from the SQL editor. contrib/auto_explain might be useful in seeing what's going on, in particular it would tell us whether or not a different plan is being used for the query inside the function. regards, tom lane -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance