<div dir="ltr"><div>Hi,</div><div><br></div><div>I'm trying to speed up the time required for msDrawMap() to execute for rendering shapefiles. Currently, according to the mapserver logs, it's taking 2.5-3.5 seconds, sometimes up to 5 seconds for it to execute:</div><div><br></div><div style="margin-left:40px">[Wed Dec 6 18:43:47 2023].699791 CGI Request 53 on process 2641<br>[Wed Dec 6 18:43:47 2023].717216 msDrawMap(): rendering using outputformat named png (AGG/PNG).<br>[Wed Dec 6 18:43:52 2023].299580 msDrawMap(): Layer 1010 (Shapefile_Layer), 4.582s<br>[Wed Dec 6 18:43:52 2023].299792 msDrawMap(): Drawing Label Cache, 0.000s<br>[Wed Dec 6 18:43:52 2023].299803 msDrawMap() total time: 4.584s<br>[Wed Dec 6 18:43:52 2023].310853 msSaveImage(stdout) total time: 0.011s</div><div style="margin-left:40px">[Wed Dec 6 18:43:52 2023].310883 mapserv request processing time (msLoadMap not incl.): 4.611s</div><div style="margin-left:40px"><br></div><div>The mapfile is currently set up using "CONNECTIONTYPE OGR" and "CONNECTION" to access the shapefiles from an S3 bucket as follows:</div><div style="margin-left:40px"><br></div><div style="margin-left:40px">CONNECTIONTYPE OGR<br>CONNECTION '/vsis3/s3_bucket_path/my_shapefile%.shp'</div><div style="margin-left:40px"><br></div><div>I noticed at <a href="https://mapserver.org/input/vector/shapefiles.html">https://mapserver.org/input/vector/shapefiles.html</a> that it says "Shapefile access is built directly into MapServer. It is also available
through OGR, but direct access without OGR is recommended and discussed here."</div><div>So I tried removing "CONNECTIONTYPE OGR" and changing "CONNECTION" to "DATA" as follows:</div><div><br></div><div style="margin-left:40px"> DATA '/vsis3/s3_bucket_path/my_shapefile%.shp'</div><div style="margin-left:40px"><br></div><div>I haven't been able to observe any definitive speed improvements by doing this yet, although I can't say for sure that there aren't any.</div><div><br></div><div>Based on <a href="https://mapserver.org/optimization/vector.html">https://mapserver.org/optimization/vector.html</a>, I also tried using the shptree command to create a spatial index and the coshp command to sort the shapefile and index. Even after doing that, I still see load msDrawMap() times of up to 5 seconds.</div><div><br></div><div>Does anyone know of any other optimizations that could be made here? Or if not, would using shptree and coshp on the shapefile and then accessing it in the mapfile using "DATA" to take it from S3 be the optimal way to set things up?<br></div><div><br></div><div>Thanks!</div><div>Matt<br></div></div>