<div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Thanks.</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">It worrks now with good performance.</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Again, thanks.</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Nahum.<br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2018-05-29 1:20 GMT-05:00 Marcin Mionskowski <span dir="ltr"><<a href="mailto:mionskowskimarcin@gmail.com" target="_blank">mionskowskimarcin@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">1. To cast resulting geom to linestring try "st_intersection(adoquin.geom,<wbr>pol.geom)::geometry(Linestring<wbr>,32614)" in your SELECT clause.<br>
<br>
2. && operator will check if bounding boxes of your geoms intersects. Your check on ST_IsEmpty(..) is basicaly the same as ST_Intersects(...) check, and the second does not involve ST_Intersection(...). I think, that the query should perform better with && combined with ST_Intersects (in my testing it is ~25% faster).<br>
If your intersections can be a multilinestrings or points, then IMO you need WHERE condition "and geometrytype(st_intersection(a<wbr>doquin.geom,pol.geom))='LINEST<wbr>RING'". If you add this to your query, then try its performance with ST_IsEmpty() and ST_Intersects() checks.<br>
<br>
Regards,<br>
Marcin<div class="HOEnZb"><div class="h5"><br>
<br>
<br>
On Fri, 25 May 2018 21:42:54 +0200, Nahum Castro <<a href="mailto:nahumcastro@gmail.com" target="_blank">nahumcastro@gmail.com</a>> wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello all.<br>
<br>
Can you help me on the next:<br>
<br>
I can create a materialized view like this to extract data from other<br>
tables within a polygon,<br>
<br>
query:<br>
create materialized view vm_adoquin as<br>
select adoquin.gid,<a href="http://adoquin.id" rel="noreferrer" target="_blank">adoquin.id</a>,adoquin<wbr>.control,st_intersection(<wbr>adoquin.geom,<br>
pol.geom) as geom<br>
from  adoquin, municipio pol<br>
where pol.municipio = 23<br>
and adoquin.geom && pol.geom<br>
and ST_IsEmpty(ST_Intersection(ado<wbr>quin.geom, pol.geom)) != TRUE;<br>
<br>
the resulting materialized view has geom type GEOMETRY but I need the geom<br>
type as LINESTRING<br>
<br>
How I can cast the view if I know that<br>
geometrytype(st_intersection(a<wbr>utopista.geom, pol.geom))=LINESTRING<br>
<br>
but can't use<br>
<br>
st_intersection(autopista.geom<wbr>,<br>
pol.geom)::geometry(geometryty<wbr>pe(st_intersection(autopista.<wbr>geom,<br>
pol.geom)), 32614) to cast because can't use functions in type conversions.<br>
<br>
<br>
<br>
Thanks in advance.<br>
Nahum<br>
</blockquote>
</div></div></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><b>Nahum Castro González</b><br>Blvd. Perdigón 214, Brisas del Lago.<br>
CP 37207<br>
León, Guanajuato, México<br>
Tel (477)1950304<br></div>Cel (477)1274694<br></div></div>
</div>