Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YZorX-0002fq-13 for pgsql-bugs@arkaria.postgresql.org; Sun, 22 Mar 2015 23:00:55 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YZorV-0006rP-Ji for pgsql-bugs@arkaria.postgresql.org; Sun, 22 Mar 2015 23:00:53 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YZorU-0006rI-EC for pgsql-bugs@postgresql.org; Sun, 22 Mar 2015 23:00:52 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YZorN-0002Ol-59 for pgsql-bugs@postgresql.org; Sun, 22 Mar 2015 23:00:50 +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 t2MN0eWr003961; Sun, 22 Mar 2015 19:00:40 -0400 From: Tom Lane To: "Paragon Corporation" cc: "'David G. Johnston'" , pgsql-bugs@postgresql.org, "'PostGIS Development Discussion'" Subject: Re: BUG #12869: PostGIS 2.2 can't compile against 9.5 dev branch In-reply-to: <002401d064f2$0d10c350$273249f0$@pcorp.us> References: <001c01d0647a$397bb260$ac731720$@pcorp.us> <14130.1427035560@sss.pgh.pa.us> <14986.1427037326@sss.pgh.pa.us> <000401d064be$5bfd11a0$13f734e0$@pcorp.us> <2721.1427062576@sss.pgh.pa.us> <002401d064f2$0d10c350$273249f0$@pcorp.us> Comments: In-reply-to "Paragon Corporation" message dated "Sun, 22 Mar 2015 18:46:34 -0400" Date: Sun, 22 Mar 2015 19:00:40 -0400 Message-ID: <3960.1427065240@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-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org "Paragon Corporation" writes: > The more common use case (the ones I am really worried about are cases where > we have a function that takes a large composite object and outputs another > which then gets passed to another PostGIS function that cuts off small > pieces. > Here one that come to mind > SELECT ST_GeometryN(newgeom,1) As geom1, ST_GeometryN(newgeom,2) As geom2 > FROM ( > SELECT ST_Simplify(geom,25) As newgeom > FROM sometable) As foo; > If I am not mistaken -- please correct me if I am wrong. The above example > would cause ST_Simplify to be called for each ST_GeometryN. Indeed, and that is exactly what happens in every PG release for time out of mind, if that's actually how you're coding it without using any method that would prevent flattening of the subquery. Check it with EXPLAIN VERBOSE if you doubt that. The patch I committed two weeks ago has no impact whatsoever on this example, because that's not a table-free subquery. I suspect that (a) you are using OFFSET 0 in the subquery, (b) you already have ST_Simplify marked as volatile, or (c) the performance hit from multiple evaluations isn't as drastic as you think. regards, tom lane -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs