<div dir="ltr"><div>"GroupAggregate (cost=324001.58..329989.92 rows=21516 width=28454)"<br>" -> Sort (cost=324001.58..324055.53 rows=21582 width=28454)"<br>" Sort Key: bacini.codice_bac, bacini.nome, bacini.codice_cor, particellepac2006.descrizione"<br>
" -> Nested Loop (cost=59426.24..59835.94 rows=21582 width=28454)"<br>" -> Seq Scan on bacini_elementari bacini (cost=0.00..138.27 rows=327 width=28397)"<br>" -> Materialize (cost=59426.24..59428.06 rows=66 width=57)"<br>
" -> HashAggregate (cost=59426.24..59427.07 rows=66 width=1169)"<br>" -> Seq Scan on particellepac2006 (cost=0.00..56355.83 rows=614083 width=1169)"<br>
</div>Thanks!<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">2014-03-13 15:15 GMT+01:00 Marcelo Soares Souza [via PostGIS] <span dir="ltr"><<a href="/user/SendEmail.jtp?type=node&node=5005874&i=0" target="_top" rel="nofollow" link="external">[hidden email]</a>></span>:<br>
<blockquote style='border-left:2px solid #CCCCCC;padding:0 1em' class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="">
Use EXPLAIN to show the execution plan of a statement, and post here.
<br><br></div> EXPLAIN SELECT sum(st_area(ST_Intersection(bacini.geom,colture.geom))) as areacoltura, codice_bac, nome, codice_cor, colture.descrizione FROM drologia.bacini_elementari as bacini, (SELECT st_collect(geom) as geom, descrizione FROM varie.particellepac2006 group by 2) as colture group by 2,3,4,5;
<br><div class=""><br>March 13 2014 11:00 AM, "Pietro Rossin" wrote:
<br></div><div><div><div class="h5"><div class='shrinkable-quote'><br>> Hi all
<br>> I'm trying to query 2 vector layers;
<br>> b) bacini_elementari that is river basins - 327 elements
<br>> b) particellepac2006 colture parcels - 614000 elements
<br>>
<br>> I want to intersect these two layers and get the sum of the area of each
<br>> kind of colture for each river basin.
<br>> To reduce the number of colture vectorial features I made a collect query
<br>> (grouping by kind of colture) and I made a intersection between this
<br>> geometry aggregation and all 327 basins.
<br>>
<br>> My query is:
<br>>
<br>> SELECT sum(st_area(ST_Intersection(bacini.geom,colture.geom))) as
<br>> areacoltura, codice_bac, nome, codice_cor, colture.descrizione
<br>> FROM idrologia.bacini_elementari as bacini,
<br>> (SELECT st_collect(geom) as geom, descrizione
<br>> FROM varie.particellepac2006
<br>> group by 2) as colture
<br>> group by 2,3,4,5
<br>>
<br>> it's 5000000ms that the query is running and I don't have any result yet...
<br>>
<br>> The two geometry column have an index (but I think it's not used in this
<br>> query)
<br>>
<br>> Mi pc id dual opteron with 4Gb RAM,
<br>> "PostgreSQL 9.1.3, compiled by Visual C++ build 1500, 32-bit"
<br>>
<br>> "POSTGIS="2.0.0 r9605" GEOS="3.3.3-CAPI-1.7.4" PROJ="Rel. 4.8.0, 6 March
<br>> 2012" GDAL="GDAL 1.9.0, released 2011/12/29" LIBXML="2.7.8"
<br>> LIBJSON="UNKNOWN" TOPOLOGY RASTER"
<br>>
<br>> --
<br>> View this message in context: <a href="http://postgis.17.x6.nabble.com/Query-performance-really-slow-tp5005872.html" rel="nofollow" link="external" target="_blank">http://postgis.17.x6.nabble.com/Query-performance-really-slow-tp5005872.html</a></div>
> Sent from the PostGIS - User mailing list archive at Nabble.com.
<br>> _______________________________________________
<br>> postgis-users mailing list
<br></div></div>> <a href="http://user/SendEmail.jtp?type=node&node=5005873&i=0" rel="nofollow" link="external" target="_blank">[hidden email]</a>
<br>> <a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users" rel="nofollow" link="external" target="_blank">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users</a><br>>
</div>_______________________________________________
<br>postgis-users mailing list
<br><a href="http://user/SendEmail.jtp?type=node&node=5005873&i=1" rel="nofollow" link="external" target="_blank">[hidden email]</a>
<br><a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users" rel="nofollow" link="external" target="_blank">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users</a><br>
<br>
<br>
<hr color="#cccccc" noshade size="1">
<div style="color:#444;font:12px tahoma,geneva,helvetica,arial,sans-serif">
<div style="font-weight:bold">If you reply to this email, your message will be added to the discussion below:</div>
<a href="http://postgis.17.x6.nabble.com/Query-performance-really-slow-tp5005872p5005873.html" target="_blank" rel="nofollow" link="external">http://postgis.17.x6.nabble.com/Query-performance-really-slow-tp5005872p5005873.html</a>
</div>
<div style="color:#666;font:11px tahoma,geneva,helvetica,arial,sans-serif;margin-top:.4em;line-height:1.5em">
To unsubscribe from Query performance really slow.., <a href="" target="_blank" rel="nofollow" link="external">click here</a>.<br>
<a href="http://postgis.17.x6.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml" rel="nofollow" style="font:9px serif" target="_blank" link="external">NAML</a>
</div></blockquote></div><br></div>
<br/><hr align="left" width="300" />
View this message in context: <a href="http://postgis.17.x6.nabble.com/Query-performance-really-slow-tp5005872p5005874.html">Re: Query performance really slow..</a><br/>
Sent from the <a href="http://postgis.17.x6.nabble.com/PostGIS-User-f3516033.html">PostGIS - User mailing list archive</a> at Nabble.com.<br/>