<p class="MsoNormal" style="BACKGROUND: white; MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left" align="left"><span style="FONT-FAMILY: Arial; mso-ansi-language: EN-US">Hi Ibrahim and Webb,</span></p>
<p class="MsoNormal" style="BACKGROUND: white; MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left" align="left"><span style="FONT-FAMILY: Arial; mso-ansi-language: EN-US"> </span></p>
<p class="MsoNormal" style="BACKGROUND: white; MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left" align="left"><span style="FONT-FAMILY: Arial; mso-ansi-language: EN-US">I will like to summarize some points that in my case, take me a time to understand how to improve the Mapserver - Postgis interaction:
</span></p>
<p class="MsoNormal" style="BACKGROUND: white; MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left" align="left"><span style="FONT-FAMILY: Arial; mso-ansi-language: EN-US"> </span></p>
<p class="MsoNormal" style="BACKGROUND: white; MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left" align="left"><span style="FONT-FAMILY: Arial; mso-ansi-language: EN-US">You need a table with an index, in the old versions of Postgres there where by default created with OIDS, the latest version doesn't do this:
</span></p>
<p class="MsoNormal" style="BACKGROUND: white; MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left" align="left"><span style="FONT-FAMILY: Arial; mso-ansi-language: EN-US"> </span></p>
<p class="MsoNormal" style="BACKGROUND: white; MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left" align="left"><span style="FONT-FAMILY: Arial; mso-ansi-language: EN-US">CREATE TABLE test.geotable(</span></p>
<p class="MsoNormal" style="BACKGROUND: white; MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left" align="left"><span style="FONT-FAMILY: Arial; mso-ansi-language: EN-US"> id_geom serial -- this is necesary for Mapserver</span></p>
<p class="MsoNormal" style="BACKGROUND: white; MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left" align="left"><span style="FONT-FAMILY: Arial; mso-ansi-language: EN-US">);</span></p>
<p class="MsoNormal" style="BACKGROUND: white; MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left" align="left"><span style="FONT-FAMILY: Arial; mso-ansi-language: EN-US">SELECT AddGeometryColumn('test','geotable','poly',32719,2);
</span></p>
<p class="MsoNormal" style="BACKGROUND: white; MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left" align="left"><span style="FONT-FAMILY: Arial; mso-ansi-language: EN-US"> </span></p>
<p class="MsoNormal" style="BACKGROUND: white; MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left" align="left"><span style="FONT-FAMILY: Arial; mso-ansi-language: EN-US">(In the following example I am using and SRID 32719)</span></p>
<p class="MsoNormal" style="BACKGROUND: white; MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left" align="left"><span style="FONT-FAMILY: Arial; mso-ansi-language: EN-US"> </span></p>
<p class="MsoNormal" style="BACKGROUND: white; MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left" align="left"><span style="FONT-FAMILY: Arial; mso-ansi-language: EN-US">You must create a GIST index if you really want to improve the postgis (&&, ..) functions, (see point
<a href="http://4.7.2.3">4.7.2.3</a> on documentation<b>)</b>:</span></p>
<p class="MsoNormal" style="BACKGROUND: white; MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left" align="left"><span style="FONT-FAMILY: Arial; mso-ansi-language: EN-US"> </span></p>
<p class="MsoNormal" style="BACKGROUND: white; MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left" align="left"><span style="FONT-FAMILY: Arial; mso-ansi-language: EN-US">CREATE INDEX gistid_poly_test ON test.geotable USING GIST(poly GIST_GEOMETRY_OPS);
</span></p>
<p class="MsoNormal" style="BACKGROUND: white; MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left" align="left"><span style="FONT-FAMILY: Arial; mso-ansi-language: EN-US"> </span></p>
<p class="MsoNormal" style="BACKGROUND: white; MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left" align="left"><span style="FONT-FAMILY: Arial; mso-ansi-language: EN-US">If you have a large amount of geometries (poly in our example), it is a good idea to cluster them using the GIST index. This is something that improve the disk access time. Please keep in mind that after you change the geometry information, you need to redo the cluster. A good recommendation is to do this task every day on changing tables:
</span></p>
<p class="MsoNormal" style="BACKGROUND: white; MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left" align="left"><span style="FONT-FAMILY: Arial; mso-ansi-language: EN-US"> </span></p>
<p class="MsoNormal" style="BACKGROUND: white; MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left" align="left"><span style="FONT-FAMILY: Arial; mso-ansi-language: EN-US">At the creation time of the table I recommend to include the following instruction:
</span></p>
<p class="MsoNormal" style="BACKGROUND: white; MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left" align="left"><span style="FONT-FAMILY: Arial; mso-ansi-language: EN-US"> </span></p>
<p class="MsoNormal" style="BACKGROUND: white; MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left" align="left"><span style="FONT-FAMILY: Arial; mso-ansi-language: EN-US">ALTER TABLE test.geotable CLUSTER ON gist_poly_test;</span></p>
<p class="MsoNormal" style="BACKGROUND: white; MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left" align="left"><span style="FONT-FAMILY: Arial; mso-ansi-language: EN-US"> </span></p>
<p class="MsoNormal" style="BACKGROUND: white; MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left" align="left"><span style="FONT-FAMILY: Arial; mso-ansi-language: EN-US">Then, on the daily work only you need to instruct:</span></p>
<p class="MsoNormal" style="BACKGROUND: white; MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left" align="left"><span style="FONT-FAMILY: Arial; mso-ansi-language: EN-US"> </span></p>
<p class="MsoNormal" style="BACKGROUND: white; MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left" align="left"><span style="FONT-FAMILY: Arial; mso-ansi-language: EN-US">SELECT CLUSTER test.geotable;</span></p>
<p class="MsoNormal" style="BACKGROUND: white; MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left" align="left"><span style="FONT-FAMILY: Arial; mso-ansi-language: EN-US"> </span></p>
<p class="MsoNormal" style="BACKGROUND: white; MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left" align="left"><span style="FONT-FAMILY: Arial; mso-ansi-language: EN-US">Within the PHP command I strongly recommend to use the index, (point
<a href="http://4.7.2.4">4.7.2.4</a> of the documentation) as well as the SRID (4.7.3) in the Mapserver command:</span></p>
<p class="MsoNormal" style="BACKGROUND: white; MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left" align="left"><span style="FONT-FAMILY: Arial; mso-ansi-language: EN-US"> </span></p>
<p class="MsoNormal" style="BACKGROUND: white; MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left" align="left"><span style="FONT-FAMILY: Arial; mso-ansi-language: EN-US">DATA "poly FROM test.geotable USING UNIQUE id_geom USING SRID=32719"
</span></p>
<p class="MsoNormal" style="BACKGROUND: white; MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left" align="left"><span style="FONT-FAMILY: Arial; mso-ansi-language: EN-US"> </span></p>
<p class="MsoNormal" style="BACKGROUND: white; MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left" align="left"><span style="FONT-FAMILY: Arial; mso-ansi-language: EN-US">You must use capital letters for 'USING UNIQUE' and 'USING SRID' (otherwise the parser for Mapserver will not understand)
</span></p>
<p class="MsoNormal" style="BACKGROUND: white; MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left" align="left"><span style="FONT-FAMILY: Arial; mso-ansi-language: EN-US"> </span></p>
<p class="MsoNormal" style="BACKGROUND: white; MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left" align="left"><span style="FONT-FAMILY: Arial; mso-ansi-language: EN-US">As the Postgis documentation mention, this is something optional. But, keep in mind that if you instruct Mapserver in the following way:
</span></p>
<p class="MsoNormal" style="BACKGROUND: white; MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left" align="left"><span style="FONT-FAMILY: Arial; mso-ansi-language: EN-US"> </span></p>
<p class="MsoNormal" style="BACKGROUND: white; MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left" align="left"><span style="FONT-FAMILY: Arial; mso-ansi-language: EN-US">DATA "poly FROM test.geotable"</span></p>
<p class="MsoNormal" style="BACKGROUND: white; MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left" align="left"><span style="FONT-FAMILY: Arial; mso-ansi-language: EN-US"> </span></p>
<p class="MsoNormal" style="BACKGROUND: white; MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left" align="left"><span style="FONT-FAMILY: Arial; mso-ansi-language: EN-US">It will also work but making two additional SELECT instructions to draw: (one to get the version of postgis, second to know the id_geom index, and finally within the select poly it will use a function to detect the SRID of the poly - in our example 32719).
</span></p>
<p class="MsoNormal" style="BACKGROUND: white; MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left" align="left"><span style="FONT-FAMILY: Arial; mso-ansi-language: EN-US"> </span></p>
<p class="MsoNormal" style="BACKGROUND: white; MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left" align="left"><span style="FONT-FAMILY: Arial; mso-ansi-language: EN-US">If someone have other suggestions, I will appreciate comments, to improve the speed of Mapserver.
</span></p>
<p class="MsoNormal" style="BACKGROUND: white; MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left" align="left"><span style="FONT-FAMILY: Arial; mso-ansi-language: EN-US"> </span></p>
<p class="MsoNormal" style="BACKGROUND: white; MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left" align="left"><span style="FONT-FAMILY: Arial; mso-ansi-language: EN-US">Regards,</span></p>
<p class="MsoNormal" style="BACKGROUND: white; MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left" align="left"><span style="FONT-FAMILY: Arial; mso-ansi-language: EN-US"> </span></p>
<p class="MsoNormal" style="BACKGROUND: white; MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left" align="left"><span style="FONT-FAMILY: Arial; mso-ansi-language: EN-US">Julio</span></p>
<div><span class="gmail_quote"></span> </div>
<div><span class="gmail_quote">On 4/16/07, <b class="gmail_sendername">TECHER David</b> <<a href="mailto:davidtecher@yahoo.fr">davidtecher@yahoo.fr</a>> wrote:</span></div>
<div>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">Hi Ibrahim<br><br>Please take a look at<br><a href="http://postgis.refractions.net/docs/ch04.html#id2709413">
http://postgis.refractions.net/docs/ch04.html#id2709413</a> questions<br><a href="http://4.7.2.3">4.7.2.3</a> and <a href="http://4.7.2.4">4.7.2.4</a><br><br>I hope these helps!<br><br>Ibrahim Khachab a écrit :<br>> Hi to you all,
<br>><br>> I'm new with geographic data and I'm trying to set a server with<br>> mapserver/posgis.<br>> It is a dual Xeon 2.8Ghz cpus machine with 2Gbyte of Ram.<br>> I have some data in SHP files that I converted to postgis data with
<br>> shp2pgsql.<br>> I made some test with some map file and I noticed a strange thing:<br>> The same maps with the shp file are 10 times faster than those with<br>> the Postgis data.<br>> What can be the problem.
<br>> How I may debug about this?<br>> I'm trying to read a lot these days about Postgresql perfoemance but<br>> till now I found nothing that could change this situation.<br>><br>><br>> Thanks<br>>
<br>> Ibrahim<br>> _______________________________________________<br>> postgis-users mailing list<br>> <a href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a><br>>
<a href="http://postgis.refractions.net/mailman/listinfo/postgis-users">http://postgis.refractions.net/mailman/listinfo/postgis-users</a><br>><br><br><br><br><br><br><br>___________________________________________________________________________
<br>Yahoo! Mail réinvente le mail ! Découvrez le nouveau Yahoo! Mail et son interface révolutionnaire.<br><a href="http://fr.mail.yahoo.com">http://fr.mail.yahoo.com</a><br>_______________________________________________<br>
postgis-users mailing list<br><a href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a><br><a href="http://postgis.refractions.net/mailman/listinfo/postgis-users">http://postgis.refractions.net/mailman/listinfo/postgis-users
</a><br></blockquote></div><br>