Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YZodp-00029n-Jb for pgsql-bugs@arkaria.postgresql.org; Sun, 22 Mar 2015 22:46:45 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YZodp-0004O9-2Q for pgsql-bugs@arkaria.postgresql.org; Sun, 22 Mar 2015 22:46:45 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YZodo-0004O3-Dp for pgsql-bugs@postgresql.org; Sun, 22 Mar 2015 22:46:44 +0000 Received: from mail.pcorp.us ([204.51.253.130]) by magus.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YZodj-0003hp-95 for pgsql-bugs@postgresql.org; Sun, 22 Mar 2015 22:46:43 +0000 Received: from R (50-78-240-110-static.hfc.comcastbusiness.net [50.78.240.110]) by mail.pcorp.us ; Sun, 22 Mar 2015 18:46:33 -0400 From: "Paragon Corporation" To: "'Tom Lane'" Cc: "'David G. Johnston'" , , "'PostGIS Development Discussion'" 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> In-Reply-To: <2721.1427062576@sss.pgh.pa.us> Subject: Re: BUG #12869: PostGIS 2.2 can't compile against 9.5 dev branch Date: Sun, 22 Mar 2015 18:46:34 -0400 Message-ID: <002401d064f2$0d10c350$273249f0$@pcorp.us> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook 15.0 Content-Language: en-us Thread-Index: AQIsS8w/PfkIE5LGw+gCOrb8ZPezLQGoZKH1ANggLwQB/ufkmgHn2dACArCrmU8A2YsAKwHd658VnBLMGsA= 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 Sorry for cross post. I've cc'd PostGIS dev group on this for input -- For PostGIS folks - link to related issue that started this conversation here: http://trac.osgeo.org/postgis/ticket/3080 >> "Paragon Corporation" writes: >> Guys I tried increasing cost with the ST_Reclass function to 2000 and it didn't help. The function is called for every single output. The only thing that helps is setting this to VOLATILE as Tom suggests. I guess we >> can do that as some sort of fix for these kinds of functions though I'm not sure if that would cause other issues. > I think that would be a very bad idea; it would foreclose optimizations that you *do* want. Much better, > if you are relying on single-evaluation behavior for a non-volatile function, is to use one of the documented optimization fences: either a CTE, or an OFFSET 0 in a sub-select. The CTE / OFFSET solution requires the end-user to do this, which means a lot of people using PostGIS may suffer severe performance issues after upgrading to PostgreSQL 9.5 unless they change their code which is something I'd like to avoid. > TBH, this particular example does not fill me with concern, because > (a) it's obviously artificial, and (b) you'd really never notice if the function got evaluated 3 times not once, if you hadn't put in that NOTICE. > I grant that there may be cases where you're worried about avoiding multiple evaluations *per row* over some large number of rows, but to discuss that type of problem we'd have to see what your coding > habits are like for such cases. An immutable function being fed constants is not going to create that type of problem. > regards, tom lane The particular constant example I presented was simply to provide an example that exhibits this behavior without having to require PostGIS to replicate it. 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. If that were the case, this would be a huge PostGIS performance killer for a lot of folks as this pattern is very common and we have a lot of expensive functions that do this kind of thing. -- PostGIS raster is filled with a ton of these. The ST_Reclass is just one example of these (and one that just happened to be tripped up by this change because it happened to have a NOTICE in it) -- things like ST_MapAlgebra that are very intensive functions that output often get used later by other functions concern me even more. Thanks, Regina -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs