<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:"Trebuchet MS";
panose-1:2 11 6 3 2 2 2 2 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";
mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal;
font-family:"Arial","sans-serif";
color:windowtext;
font-weight:normal;
font-style:normal;
text-decoration:none none;}
span.EmailStyle18
{mso-style-type:personal-reply;
font-family:"Calibri","sans-serif";
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:72.0pt 90.0pt 72.0pt 90.0pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="FR-CA" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-family:"Arial","sans-serif"">Hi,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial","sans-serif""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial","sans-serif"">Experiencing something not expected with the filter condition in mapfile.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial","sans-serif""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial","sans-serif"">I add this code in my mapFile to have the possibility to void the filter if no parameter is given:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial","sans-serif""><o:p> </o:p></span></p>
<p class="MsoNormal" style="margin-bottom:12.0pt"><i><span style="font-family:"Arial","sans-serif";color:#004080">VALIDATION</span></i>
<br>
<i><span style="font-family:"Arial","sans-serif";color:#004080"> no_diag '^[0-9]{1,2}$'
</span></i><br>
<i><span style="font-family:"Arial","sans-serif";color:#004080"> default_no_diag '0'</span></i>
<br>
<i><span style="font-family:"Arial","sans-serif";color:#004080"> END</span></i> <br>
<i><span style="font-family:"Arial","sans-serif";color:#004080"> DATA "geom_surf from LOCTS_PARC_AGRI_AN_COUR using srid 4326"</span></i>
<br>
<i><span style="font-family:"Arial","sans-serif";color:#004080"> FILTER (([no_diag]='%no_diag%') or ('%no_diag%' = '0'))
</span></i><span style="font-family:"Arial","sans-serif""><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial","sans-serif"">I compare my execution time without parameter and it’s going to an execution time of 3 seconds before filter to one of 3 minutes with the filter.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial","sans-serif""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial","sans-serif"">After debugging, I realize that the « where clause » generated by MapServe were bad with the filter and that generate a full table scan :<o:p></o:p></span></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><i><span style="color:#1F497D">WHERE ( '0' = '0' ) OR ( no_diag = '0' ) AND …</span></i><o:p></o:p></p>
<p class="MsoNormal"><span style="font-family:"Arial","sans-serif"">I was expecting something more like :<o:p></o:p></span></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><i><span style="color:#1F497D">WHERE (( '0' = '0' ) OR ( no_diag = '0' )) AND …</span></i><o:p></o:p></p>
<p class="MsoNormal"><span style="font-family:"Arial","sans-serif"">So I had to add more parenthesis to the filter to get it correct<o:p></o:p></span></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><i><span style="color:#1F497D">((('%no_diag%' = '0') or ([no_diag]='%no_diag%')))
</span></i><o:p></o:p></p>
<p class="MsoNormal"><span style="font-family:"Arial","sans-serif"">Is it normal that I have to do that? The examples I found on the internet, have always single parenthesis. Do I code it right?<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial","sans-serif""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial","sans-serif"">I use Mapserver 7 with database Oracle 12c. My parameter no_diag is a number.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial","sans-serif""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial","sans-serif"">Thanks<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial","sans-serif""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Arial","sans-serif";color:black;mso-fareast-language:FR-CA">Michael Lane
</span><span style="font-size:12.0pt;font-family:"Times New Roman","serif";mso-fareast-language:FR-CA"><br>
</span><i><span style="font-size:9.0pt;font-family:"Arial","sans-serif";color:black;mso-fareast-language:FR-CA">Technicien en informatique</span></i><span style="font-size:12.0pt;font-family:"Times New Roman","serif";mso-fareast-language:FR-CA"><br>
<br>
</span><span style="font-size:9.0pt;font-family:"Arial","sans-serif";color:black;mso-fareast-language:FR-CA">Direction des solutions d'affaires</span><span style="font-size:12.0pt;font-family:"Times New Roman","serif";mso-fareast-language:FR-CA"><br>
</span><b><span style="font-size:9.0pt;font-family:"Arial","sans-serif";color:black;mso-fareast-language:FR-CA">La Financière agricole du Québec</span></b><b><span style="font-size:12.0pt;font-family:"Times New Roman","serif";mso-fareast-language:FR-CA"><br>
</span></b><span style="font-size:9.0pt;font-family:"Arial","sans-serif";color:black;mso-fareast-language:FR-CA">1400, boul. Guillaume-Couture</span><span style="font-size:12.0pt;font-family:"Times New Roman","serif";mso-fareast-language:FR-CA"><br>
</span><span style="font-size:9.0pt;font-family:"Arial","sans-serif";color:black;mso-fareast-language:FR-CA">Lévis (Québec) G6W 8K7</span><span style="font-size:12.0pt;font-family:"Times New Roman","serif";mso-fareast-language:FR-CA"><br>
</span><span style="font-size:9.0pt;font-family:"Arial","sans-serif";color:black;mso-fareast-language:FR-CA">Tél. : 418 838-5614, poste 6034</span><span style="font-size:12.0pt;font-family:"Times New Roman","serif";mso-fareast-language:FR-CA"><br>
</span><span style="font-size:9.0pt;font-family:"Arial","sans-serif";color:black;mso-fareast-language:FR-CA"><a href="mailto:Michael.Lane@fadq.qc.ca"><span style="color:blue">michael.lane@fadq.qc.ca</span></a></span><span style="font-size:12.0pt;font-family:"Times New Roman","serif";mso-fareast-language:FR-CA"><br>
<br>
</span><span style="font-size:12.0pt;font-family:"Trebuchet MS","sans-serif";color:gray;mso-fareast-language:FR-CA"><img border="0" width="106" height="33" id="_x0000_i1025" src="cid:image001.jpg@01D27723.BAB8F550"></span><span style="font-size:12.0pt;font-family:"Times New Roman","serif";mso-fareast-language:FR-CA"><br>
</span><span style="font-size:12.0pt;font-family:"Trebuchet MS","sans-serif";color:gray;mso-fareast-language:FR-CA"><img border="0" width="269" height="44" id="_x0000_i1026" src="cid:image002.jpg@01D27723.BAB8F550"></span><span style="font-size:12.0pt;font-family:"Times New Roman","serif";mso-fareast-language:FR-CA"><br>
</span><span style="font-size:12.0pt;font-family:"Trebuchet MS","sans-serif";color:gray;mso-fareast-language:FR-CA"><img border="0" width="188" height="26" id="_x0000_i1027" src="cid:image003.jpg@01D27723.BAB8F550"></span><o:p></o:p></p>
</div>
</body>
</html>