<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">Hi Dana, <br><br>Usually it does not matter much, as mapserver passes the query to Postgis anyway, as you noted. However, mapserever does do some parsing &amp; rewriting of the query before issuing it, and this can cause issues.<br><br>Also note that when working in the db, it is easier to use explain, check indexes, etc to optimise your query, so if it is anything but a simple join, I'd suggest creating it in the database is the tidier way to do this.<br><br>I guess I approach it with the premise that mapserver is the rendering engine, Postgis is the data management/query engine. If your dba is going to be able to see the views/queries/joins which the db implements, &amp; manage/optimise the db for these, it is much easier if they are inplemented in the db than scattered around in mapfiles.<br><br>This said, I use where clauses all the time in mapfiles, for
 layers based on data driven categories within a single table, for example, map LAYER DTIS = <br>"select ... where category='DTIS';", etc. I'd suggest views in this case are just clutter :-)<br><br>It is a case-by-case basis... for informed advice, seeing the actual query would be useful<br>.<br>Cheers,<br><br>&nbsp;Brent Wood<br><br>--- On <b>Fri, 4/29/11, Dara Olson <i>&lt;dolson@glifwc.org&gt;</i></b> wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><br>From: Dara Olson &lt;dolson@glifwc.org&gt;<br>Subject: [mapserver-users] Efficiency - Postgres/gis view or Mapserver data definition join<br>To: mapserver-users@lists.osgeo.org<br>Date: Friday, April 29, 2011, 6:34 AM<br><br><div id="yiv455764642">

 
 
<style></style>
<div><font face="Garamond">
<div><font face="Garamond">Greetings.&nbsp; I am hoping that I&nbsp;have posted 
this on the most appropriate list, please let me know if I should be 
posting&nbsp;to a different list. </font></div>
<div>&nbsp;</div>
<div><font face="Garamond">In our Mapserver application, we join a lot of tables 
together -&nbsp;generally one table&nbsp;with geometry to a "flat" table with 
tabular data.&nbsp; My question is - is it more efficient/faster&nbsp;to create 
a view in&nbsp;PostgreSQL doing the join and link to the view table&nbsp;from 
Mapserver&nbsp;or to define the&nbsp;join (SQL statement)&nbsp;with Mapserver in 
the data definition&nbsp;within the layer definition? Does it even matter 
because Mapserver sends the request to PostgreSQL/GIS? </font></div>
<div><font face="Garamond"></font>&nbsp;</div>
<div><font face="Garamond">Also, we have joins that take a field within the flat 
table&nbsp;to determine which table to join to get geometry.&nbsp; For example, 
if the flat table column "join" value is equal to&nbsp;1 then it joins to 
"table1" to get geometry or if column "join" value is equal to 2 then it joins 
to "table2" to get geometry. I read something that you were not supposed to use 
WHERE clauses in the Mapserver data definition.&nbsp; Would this be better to do 
as a view and link to the view table from the data definition?</font></div>
<div><font face="Garamond"></font>&nbsp;</div>
<div><font face="Garamond">Any advice would be greatly appreciated.&nbsp; Thanks 
in advance!</font></div>
<div><font face="Garamond">Dara</font></div></font></div></div><br>-----Inline Attachment Follows-----<br><br><div class="plainMail">_______________________________________________<br>mapserver-users mailing list<br><a ymailto="mailto:mapserver-users@lists.osgeo.org" href="/mc/compose?to=mapserver-users@lists.osgeo.org">mapserver-users@lists.osgeo.org</a><br><a href="http://lists.osgeo.org/mailman/listinfo/mapserver-users" target="_blank">http://lists.osgeo.org/mailman/listinfo/mapserver-users</a><br></div></blockquote></td></tr></table>