<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=us-ascii">
<meta name=Generator content="Microsoft Word 12 (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:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@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:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p
        {mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
span.emailstyle17
        {mso-style-name:emailstyle17;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.content
        {mso-style-name:content;}
span.EmailStyle21
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page Section1
        {size:612.0pt 792.0pt;
        margin:70.85pt 3.0cm 70.85pt 3.0cm;}
div.Section1
        {page:Section1;}
-->
</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=PT link=blue vlink=purple>

<div class=Section1>

<p class=MsoNormal><span lang=EN-US style='color:#1F497D'>Hello Regina,<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US style='color:#1F497D'><o:p> </o:p></span></p>

<p class=MsoNormal><span lang=EN-US style='color:#1F497D'>Txs for replying.<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US style='color:#1F497D'><o:p> </o:p></span></p>

<p class=MsoNormal><span lang=EN-US style='color:#1F497D'>You’re right. I was
missing an index for the text fields. I realized this and immediately applied
the theory with grim results… </span><span lang=EN-US style='font-family:Wingdings;
color:#1F497D'>L</span><span lang=EN-US style='color:#1F497D'><o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US style='color:#1F497D'><o:p> </o:p></span></p>

<p class=MsoNormal><span lang=EN-US style='color:#1F497D'>It turns out (?) that
one as to use TSearch2 to have the indices fired up for text fields… Someone
please rebate me if I’m wrong.<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US style='color:#1F497D'><o:p> </o:p></span></p>

<p class=MsoNormal><span lang=EN-US style='color:#1F497D'>Anyway I’m still not
ready to mess up with my tables’ schema in case someone comes up with a more
enlightened solution…<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US style='color:#1F497D'><o:p> </o:p></span></p>

<p class=MsoNormal><span lang=EN-US style='color:#1F497D'>Best regards,<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US style='color:#1F497D'>Pedro.<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US style='color:#1F497D'><o:p> </o:p></span></p>

<p class=MsoNormal><span lang=EN-US style='color:#1F497D'><o:p> </o:p></span></p>

<div>

<div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm'>

<p class=MsoNormal><b><span lang=EN-US style='font-size:10.0pt;font-family:
"Tahoma","sans-serif"'>From:</span></b><span lang=EN-US style='font-size:10.0pt;
font-family:"Tahoma","sans-serif"'>
postgis-users-bounces@postgis.refractions.net
[mailto:postgis-users-bounces@postgis.refractions.net] <b>On Behalf Of </b>Obe,
Regina<br>
<b>Sent:</b> domingo, 1 de Abril de 2007 22:34<br>
<b>To:</b> PostGIS Users Discussion<br>
<b>Subject:</b> RE: [postgis-users] Indexes not being used<o:p></o:p></span></p>

</div>

</div>

<p class=MsoNormal><o:p> </o:p></p>

<div id=idOWAReplyText1753>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif";
color:black'>I assume the srid of your t.geometry field is 4326.</span><span
style='font-size:12.0pt;font-family:"Times New Roman","serif"'><o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'> <o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>How
do you have your index specified?  If you have it something like</span><span
style='font-size:12.0pt;font-family:"Times New Roman","serif"'><o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'> <o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>CREATE
INDEX idx_pt_madeira_topnymy_geometry ON  pt_madeira_toponymy USING
GIST(transform(geometry, 4326));</span><span style='font-size:12.0pt;
font-family:"Times New Roman","serif"'><o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'> <o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>rather
than </span><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'><o:p></o:p></span></p>

</div>

<div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>CREATE
INDEX idx_pt_madeira_topnymy_geometry ON  pt_madeira_toponymy USING
GIST(geometry);</span><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'><o:p></o:p></span></p>

</div>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'> </span><span
style='font-size:12.0pt;font-family:"Times New Roman","serif"'><o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>I
don't think it will recognize it as a valid index for your query since your
query is using geometry rather than transform(geometry, 4326)</span><span
style='font-size:12.0pt;font-family:"Times New Roman","serif"'><o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'> <o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>Other
thing to check - you should have an index on your parish field.  I think
that may have better selectivity depending on how many parish are
'SE'</span><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'><o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'> <o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>Hope
that helps,</span><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'><o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>Regina</span><span
style='font-size:12.0pt;font-family:"Times New Roman","serif"'><o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span class=content><span style='font-size:10.0pt;
font-family:"Arial","sans-serif"'> </span></span><span class=content><span
style='font-size:10.0pt;font-family:"Arial","sans-serif"'><o:p></o:p></span></span></p>

</div>

</div>

<div>

<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'><o:p> </o:p></span></p>

<div class=MsoNormal align=center style='text-align:center'><span
style='font-size:12.0pt;font-family:"Times New Roman","serif"'>

<hr size=2 width="100%" align=center>

</span></div>

<p class=MsoNormal style='margin-bottom:12.0pt'><b><span style='font-size:10.0pt;
font-family:"Tahoma","sans-serif"'>From:</span></b><span style='font-size:10.0pt;
font-family:"Tahoma","sans-serif"'>
postgis-users-bounces@postgis.refractions.net on behalf of Pedro Doria Meunier<br>
<b>Sent:</b> Sat 3/31/2007 2:57 PM<br>
<b>To:</b> 'PostGIS Users Discussion'<br>
<b>Subject:</b> [postgis-users] Indexes not being used</span><span
style='font-size:12.0pt;font-family:"Times New Roman","serif"'><o:p></o:p></span></p>

</div>

<div>

<p class=MsoNormal><span lang=EN-US>Hi all (with a special wink to Regina ;- )</span><o:p></o:p></p>

<p class=MsoNormal> <o:p></o:p></p>

<p class=MsoNormal><span lang=EN-US>This is the query not using indices:</span><o:p></o:p></p>

<p class=MsoNormal> <o:p></o:p></p>

<p class=MsoNormal><span lang=EN-US>SELECT parish,county,geometry FROM pt_madeira_toponymy
as t WHERE parish=upper('se') AND</span><o:p></o:p></p>

<p class=MsoNormal><span lang=EN-US>  t.geometry &&
geomfromtext('POINT(-16.9213592631455 32.6437878212273)',4326) AND
intersects(geomfromtext('POINT(-16.9213592631455 32.6437878212273)',4326),
t.geometry);</span><o:p></o:p></p>

<p class=MsoNormal> <o:p></o:p></p>

<p class=MsoNormal><span lang=EN-US>As you can plainly see it checks if a point
is inside some polygon.</span><o:p></o:p></p>

<p class=MsoNormal> <o:p></o:p></p>

<p class=MsoNormal><span lang=EN-US>EXPLAIN ANALYZE returns this:</span><o:p></o:p></p>

<p class=MsoNormal><span lang=EN-US>"Seq Scan on pt_madeira_toponymy
t  (cost=0.00..3.03 rows=1 width=96) (actual time=1.086..1.278 rows=1
loops=1)"</span><o:p></o:p></p>

<p class=MsoNormal><span lang=EN-US>"  Filter: ((parish = 'SE'::text)
AND (geometry && '0101000020E61000009B135F33DEEB30C0FFDDAAA367524040'::geometry)
AND intersects('0101000020E61000009B135F33DEEB30C0FFDDAAA367524040'::geometry,
geometry))"</span><o:p></o:p></p>

<p class=MsoNormal><span lang=EN-US>"Total runtime: 1.312 ms"</span><o:p></o:p></p>

<p class=MsoNormal> <o:p></o:p></p>

<p class=MsoNormal><span lang=EN-US>The toponymy has two indices: one for 4326
and another for 32628 using GiST.</span><o:p></o:p></p>

<p class=MsoNormal> <o:p></o:p></p>

<p class=MsoNormal><span lang=EN-US>Is the intersects function not using
indices at all??</span><o:p></o:p></p>

<p class=MsoNormal> <o:p></o:p></p>

<p class=MsoNormal><span lang=EN-US>Already thankful for any ideas,</span><o:p></o:p></p>

<p class=MsoNormal><span lang=EN-US>With best regards,</span><o:p></o:p></p>

<p class=MsoNormal><span lang=EN-US>Pedro Doria Meunier.</span><o:p></o:p></p>

</div>

<div class=MsoNormal align=center style='text-align:center'><span
style='font-size:12.0pt;font-family:"Times New Roman","serif"'>

<hr size=1 width="100%" align=center>

</span></div>

<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'><o:p> </o:p></span></p>

<p><b><br>
<strong>The substance of this message, including any attachments, may be</strong><br>
<strong>confidential, legally privileged and/or exempt from disclosure</strong><br>
<strong>pursuant to Massachusetts law. It is intended solely for the</strong><br>
<strong>addressee. If you received this in error, please contact the sender</strong><br>
<strong>and delete the material from any computer.</strong></b><o:p></o:p></p>

</div>

</body>

</html>