Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WXhUU-0006rW-82 for pgsql-performance@arkaria.postgresql.org; Wed, 09 Apr 2014 01:39:50 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WXhUT-0002cl-CM for pgsql-performance@arkaria.postgresql.org; Wed, 09 Apr 2014 01:39:49 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WXhUS-0002ce-87 for pgsql-performance@postgresql.org; Wed, 09 Apr 2014 01:39:48 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WXhUM-0001yK-2i for pgsql-performance@postgresql.org; Wed, 09 Apr 2014 01:39:47 +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 s391deMn001310; Tue, 8 Apr 2014 21:39:40 -0400 From: Tom Lane To: uher dslij cc: pgsql-performance@postgresql.org Subject: Re: Performance regressions in PG 9.3 vs PG 9.0 In-reply-to: References: <28394.1396992397@sss.pgh.pa.us> Comments: In-reply-to uher dslij message dated "Tue, 08 Apr 2014 20:23:21 -0400" Date: Tue, 08 Apr 2014 21:39:40 -0400 Message-ID: <1309.1397007580@sss.pgh.pa.us> X-Pg-Spam-Score: -2.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 uher dslij writes: > Thanks for your reply Tom. I've found that the culprit is the function > parentContainers(), which recurses up a folder structure and looks like > this: Hmm ... I had noticed the execution of that in a subplan, but it appeared that the subplan was being done the same number of times and took about the same amount of time in both 9.0 and 9.3, so I'd discounted it as the source of trouble. Still, it's hard to argue with experimental evidence. > create function parentContainers(numeric) returns setof numeric > as ' > select parentContainers( (select container_id from container where id = > $1 ) ) > union > select id from container where id = $1 > ' language sql stable returns null on null input; Yeah, that looks like performance trouble waiting to happen --- it's not clear what would bound the recursion, for one thing. Have you considered replacing this with a RECURSIVE UNION construct? Wasn't there in 9.0 of course, but 9.3 can do that. 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