Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bQM0X-0001Y9-2O for pgsql-performance@arkaria.postgresql.org; Thu, 21 Jul 2016 21:59:53 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bQM0W-0004cT-LZ for pgsql-performance@arkaria.postgresql.org; Thu, 21 Jul 2016 21:59:52 +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_2) (envelope-from ) id 1bQM0W-0004cF-70 for pgsql-performance@postgresql.org; Thu, 21 Jul 2016 21:59:52 +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_2) (envelope-from ) id 1bQM0T-0003CQ-Os for pgsql-performance@postgresql.org; Thu, 21 Jul 2016 21:59:51 +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 u6LLxiIV015307; Thu, 21 Jul 2016 17:59:44 -0400 From: Tom Lane To: Jim Nasby cc: Robert Klemme , pgsql-performance Subject: Re: Seeing execution plan of foreign key constraint check? In-reply-to: References: <4b2f737a-ea37-35cd-012b-307ee1c9a584@BlueTreble.com> <11766.1468959038@sss.pgh.pa.us> Comments: In-reply-to Jim Nasby message dated "Thu, 21 Jul 2016 16:42:04 -0500" Date: Thu, 21 Jul 2016 17:59:44 -0400 Message-ID: <15306.1469138384@sss.pgh.pa.us> X-Pg-Spam-Score: -3.2 (---) 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 Jim Nasby writes: > On 7/19/16 3:10 PM, Tom Lane wrote: >> It's not so much that people don't care, as that it's not apparent how to >> improve this without breaking desirable system properties --- in this >> case, that functions are black boxes so far as callers are concerned. > I thought we already broke out time spent in triggers as part of > EXPLAIN, ... yes ... > and that the FK "triggers" were specifically ignored? No. You get something like # explain analyze insert into cc values(1); QUERY PLAN ------------------------------------------------------------------------------------------ Insert on cc (cost=0.00..0.01 rows=1 width=4) (actual time=0.192..0.192 rows=0 loops=1) -> Result (cost=0.00..0.01 rows=1 width=4) (actual time=0.002..0.002 rows=1 loops=1) Planning time: 0.035 ms Trigger for constraint cc_f1_fkey: time=1.246 calls=1 Execution time: 1.473 ms (5 rows) EXPLAIN does know enough about FK triggers to label them with the associated constraint name rather than calling them something like "RI_ConstraintTrigger_c_81956"; but it does not have any ability to reach inside them. > As for function plans, ISTM that could be added to the PL handlers if we > wanted to (allow a function invocation to return an array of explain > outputs). Where would you put those, particularly for functions executed many times in the query? Would it include sub-functions recursively? I mean, yeah, in principle we could do something roughly like that, but it's not easy and presenting the results intelligibly seems almost impossible. 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