<html><head></head><body><div style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:13px;"><div style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:13px;"><div><div>OK, </div><div><br></div><div>Make sure to add ORDER BY [DESC] to the Mapserver subquery to be sure that both queries have the same arguments (750) and to <span><span style="color: rgb(0, 0, 0); font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;">always get the same result.</span></span><br></div><div><span><pre style="color: rgb(0, 0, 0); word-wrap: break-word; white-space: pre-wrap;">(SELECT * FROM roronline.settings ORDER BY notice_radius DESC LIMIT 1)</pre></span></div><div>Mapserver also does the encode of geometry, that is why it takes longer than executing just the buffer. Now, if you want to know exactly why one query is faster than the other, use EXPLAIN ANALYSE and compare both execution plans:</div><div><br></div><div>EXPLAIN ANALYSE </div><div><span><div>SELECT encode(ST_AsBinary(ST_Force_2D("point"),'NDR'),'hex') as geom,"id" from (SELECT n.id AS id,ST_Buffer(n.location_3067, 750) AS point FROM roronline.notices AS n WHERE (n.valid_from < (extract(epoch from now())) AND n.valid_to > (extract(epoch from now())))) as reind where point && ST_GeomFromText('POLYGON((490679.742759776 7231264.00430746,490679.742759776 7250039.99749315,505982.257240184 7250039.99749315,505982.257240184 7231264.00430746,490679.742759776 7231264.00430746))',3067)</div><div><br></div><div>EXPLAIN ANALYSE </div><div>SELECT encode(ST_AsBinary(ST_Force_2D("point"),'NDR'),'hex') as geom,"id" from (SELECT n.id AS id,ST_Buffer(n.location_3067, s.notice_radius) AS point FROM roronline.notices AS n, (SELECT * FROM roronline.settings LIMIT 1) AS s WHERE (n.valid_from < (extract(epoch from now())) AND n.valid_to > (extract(epoch from now())))) as reind where point && ST_GeomFromText('POLYGON((490679.742759776 7231264.00430746,490679.742759776 7250039.99749315,505982.257240184 7250039.99749315,505982.257240184 7231264.00430746,490679.742759776 7231264.00430746))',3067)</div></span></div><div class="ydp222f5093signature"><br></div></div><div class="ydp222f5093signature"><span style="color: rgb(38, 40, 42);">Cheers,</span></div><div class="ydp222f5093signature"><span style="color: rgb(38, 40, 42);"><br></span></div><div class="ydp222f5093signature"><span style="color: rgb(38, 40, 42);"><br></span></div><div class="ydp222f5093signature"><span style="color: rgb(38, 40, 42);"><br></span></div><div class="ydp222f5093signature"><span style="color: rgb(38, 40, 42);">On Wednesday, September 5, 2018, 11:56:27 PM CDT, ahlah <ahti.lahtela@pp.inet.fi> wrote:</span><br></div></div><div id="ydp4a125cf7yahoo_quoted_7220371993" class="ydp4a125cf7yahoo_quoted"><div style="font-family:'Helvetica Neue', Helvetica, Arial, sans-serif;font-size:13px;color:#26282a;">
                <div><br></div>
                <div><br></div>
                <div><div dir="ltr">s.notice_radius is also 750.<div class="ydp4a125cf7yqt8007891712" id="ydp4a125cf7yqtfd46316"><br clear="none"><br clear="none"><br clear="none"><br clear="none">--<br clear="none">Sent from: <a shape="rect" href="http://osgeo-org.1560.x6.nabble.com/Mapserver-User-f4226646.html" rel="nofollow" target="_blank">http://osgeo-org.1560.x6.nabble.com/Mapserver-User-f4226646.html</a><br clear="none">_______________________________________________<br clear="none">mapserver-users mailing list<br clear="none"><a shape="rect" href="mailto:mapserver-users@lists.osgeo.org" rel="nofollow" target="_blank">mapserver-users@lists.osgeo.org</a><br clear="none"><a shape="rect" href="https://lists.osgeo.org/mailman/listinfo/mapserver-users" rel="nofollow" target="_blank">https://lists.osgeo.org/mailman/listinfo/mapserver-users</a></div></div></div>
            </div>
        </div></div></body></html>