<!DOCTYPE html><html><head><title></title><style type="text/css">#qt p.qt-MsoNormal{margin-top:0in;margin-right:0in;margin-left:0in;margin-bottom:0.0001pt;font-size:11pt;font-family:"Calibri", sans-serif;}
#qt a:link{color:rgb(5, 99, 193);text-decoration-line:underline;text-decoration-style:solid;text-decoration-color:currentcolor;}
#qt a:visited{color:rgb(149, 79, 114);text-decoration-line:underline;text-decoration-style:solid;text-decoration-color:currentcolor;}

p.MsoNormal,p.MsoNoSpacing{margin:0}</style></head><body><div>Hi,<br></div><div><br></div><div>Good question. This is a fairly new change as part of <a href="https://github.com/mapserver/mapserver/issues/5781">https://github.com/mapserver/mapserver/issues/5781</a> from April this year. <br></div><div>In SQL Profiler I seem to get GEOM.STIntersects for WFS requests and GEOM.MakeVaid().STIntersects for WMS. <br></div><div>MakeValid does appear to stop the index being used. Do you have a link which says this definitively?<br></div><div><br></div><div>Seth<br></div><div><br></div><div id="sig62266145"><div class="signature">--<br></div><div class="signature">web:http://geographika.co.uk<br></div><div class="signature">twitter: @geographika<br></div></div><div><br></div><div><br></div><div>On Sat, Sep 7, 2019, at 12:02 PM, ikeszei@yahoo.com wrote:<br></div><blockquote type="cite" id="qt"><div class="qt-WordSection1"><p class="qt-MsoNormal">Hello,<br></p><p class="qt-MsoNormal"> <br></p><p class="qt-MsoNormal">I noticed that when MapServer issues the query to MS SQL Server, it appends a .MakeValid() tag to the geometry field, which makes data access highly inefficient as no spatial indexes can be used when the MakeValid() is used. Here is the query that is being produced:<br></p><p class="qt-MsoNormal"> <br></p><p class="qt-MsoNormal">SELECT<br></p><p style="text-indent:0.5in;" class="qt-MsoNormal">convert(nvarchar(max), [label]),<br></p><p style="text-indent:0.5in;" class="qt-MsoNormal">[ogr_geometry],<br></p><p style="text-indent:0.5in;" class="qt-MsoNormal">convert(varchar(36), [ogr_fid])<br></p><p class="qt-MsoNormal">FROM<br></p><p style="text-indent:0.5in;" class="qt-MsoNormal">section<br></p><p class="qt-MsoNormal">WHERE<br></p><p style="text-indent:0.5in;" class="qt-MsoNormal">ogr_geometry.<b><span style="color:red" class="colour">MakeValid()</span></b>.STIntersects(geometry::STGeomFromText('POLYGON((-10973271.1167343 5605636.0681215,-10963019.0003155 5605636.0681215,-10963019.0003155 5614459.76757417,-10973271.1167343 5614459.76757417,-10973271.1167343 5605636.0681215))',3857)) = 1<br></p><p class="qt-MsoNormal"> <br></p><p class="qt-MsoNormal">Here is the data access string from the map file:<br></p><p class="qt-MsoNormal"> <br></p><p class="qt-MsoNormal"><b>DATA "ogr_geometry from section USING UNIQUE ogr_fid USING SRID=3857"</b><br></p><p class="qt-MsoNormal"> <br></p><p class="qt-MsoNormal">Earlier I was using a specific HINT for index usage:<br></p><p class="qt-MsoNormal"> <br></p><p class="qt-MsoNormal"><b>DATA "ogr_geometry from section WITH (INDEX(section_ogr_geometry_idx)) USING UNIQUE ogr_fid USING SRID=3857"</b><br></p><p class="qt-MsoNormal"> <br></p><p class="qt-MsoNormal">But since MapServer adds the MakeValid automatically, I am getting the following error:<br></p><p class="qt-MsoNormal"> <br></p><p style="" class="qt-MsoNormal"><span style="background-color:white" class="highlight"><span style="color:black" class="colour"><span style="font-family:Consolas" class="font"><span style="font-size:9.5pt" class="size">Msg 8635, Level 16, State 9, Line 1</span></span></span></span><br></p><p style="" class="qt-MsoNormal"><span style="background-color:white" class="highlight"><span style="color:black" class="colour"><span style="font-family:Consolas" class="font"><span style="font-size:9.5pt" class="size">The query processor could not produce a query plan for a query with a spatial index hint.  Reason: Could not find required binary spatial method in a condition.  Try removing the index hints or removing SET FORCEPLAN.</span></span></span></span><br></p><p class="qt-MsoNormal"> <br></p><p class="qt-MsoNormal">How do I configure mapserver to NOT ADD the MakeValid to every single one of its queries ?<br></p><p class="qt-MsoNormal"> <br></p><p class="qt-MsoNormal">Any response is much appreciated !<br></p><p class="qt-MsoNormal"> <br></p><p class="qt-MsoNormal">Thanks,<br></p><p class="qt-MsoNormal">Istvan<br></p><p class="qt-MsoNormal"> <br></p><p class="qt-MsoNormal"> <br></p></div><div>_______________________________________________<br></div><div>mapserver-users mailing list<br></div><div>mapserver-users@lists.osgeo.org<br></div><div>https://lists.osgeo.org/mailman/listinfo/mapserver-users<br></div></blockquote><div><br></div></body></html>