<div dir="ltr"><div dir="ltr"><div class="gmail_default">Hi Hugo  <font face="garamond, serif" size="4"><br></font></div><div class="gmail_default"><font face="garamond, serif" size="4">but the _search_frame_ is always usable ?? or only in special cases?</font><br></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Il giorno gio 2 mag 2019 alle ore 17:18 Andreas Neumann <<a href="mailto:a.neumann@carto.net">a.neumann@carto.net</a>> ha scritto:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Hugo,<br>
<br>
Indeed  - when I add the test against the _search_frame_ - everthing <br>
works almost equally fast than within Postgis. Certainly now the virtual <br>
layer suddenly becomes useful and fast enough for us.<br>
<br>
But to be honest - I would never have guessed that. I was searching for <br>
the "&&" operator that was necessary in the old days of Postgis (the <br>
bounding box test). Is this something similar?<br>
<br>
Perhaps there should be a visible hint for that in the Virtual layer <br>
creation dialogue? Googling for it reveals a section in the manual ;-) <br>
<a href="https://docs.qgis.org/3.4/en/docs/user_manual/managing_data_source/create_layers.html#use-of-indexes" rel="noreferrer" target="_blank">https://docs.qgis.org/3.4/en/docs/user_manual/managing_data_source/create_layers.html#use-of-indexes</a><br>
<br>
Would be useful to add a button to the dialogue - a button like <br>
"Performance hints" that would open this section in the manual.<br>
<br>
Many thanks - you will make my colleagues happy! I told them they have <br>
to do everything in Postgis and not mix data formats.<br>
<br>
Matteo and Toto: can you try if that helps in your cases as well? Would <br>
be interesting to know.<br>
<br>
Greetings,<br>
<br>
Andreas<br>
<br>
PS: with the 40 seconds before I thought - well - I as a slow human <br>
might be even faster than that stupid computer. Who knows ... I could <br>
have been faster! Now with Hugos hint is also a sub-second query.<br>
<br>
Am 02.05.19 um 16:36 schrieb Hugo Mercier:<br>
> Hi,<br>
><br>
> One big difference between spatialite and PostGIS is that PostGIS is<br>
> able to use spatial indexes transparently, while spatialite cannot.<br>
><br>
> Could you try with something like " ... AND lie._search_frame_ =<br>
> tbap.geometry" ?<br>
><br>
><br>
> On 02/05/2019 11:02, Andreas Neumann wrote:<br>
>> Hi,<br>
>><br>
>> One of my colleagues created a QGIS project where they loaded a parcel<br>
>> layer with approx. 24000 polygons (data source Postgis) and another<br>
>> layer with 3 polygons representing project perimeters of contruction<br>
>> sites. That second layer is in a Geopackage.<br>
>><br>
>> Now they want to select all parcels that are intersecting the project<br>
>> perimeters.<br>
>><br>
>> The query is straightforward:<br>
>><br>
>> SELECT lie.nummer_grundstueck, lie.gemeinde, tbap.bemerkungen, lie.geometry<br>
>> FROM lie_liegenschaft lie, tba_projektperimeter tbap<br>
>> WHERE ST_Intersects(lie.geometry, tbap.geometry)<br>
>><br>
>> Now the problem is: this query (24000 parcels, 3 project perimeters) is<br>
>> just incredibly slow: about 40 seconds. In a Postgis view this would be<br>
>> way less then a second! The worst thing: that virtual layer is updated<br>
>> with each and every zoom and pan. Is there no way to cache a virtual layer?<br>
>><br>
>> Can I do something to speed up our virtual layer? The parcel layer only<br>
>> chanes once a month and the perimeters only occasionally, so it would be<br>
>> best to cache the result within a QGIS session, because there are no<br>
>> changes in the geometries of both layers expected.<br>
>><br>
>> I understand that virtual layers somehow have to transfer all data<br>
>> formats (through ogr) into SpatiaLite or SQLite to do the query, but<br>
>> this is really way too slow for real world usage in my opinion (unless I<br>
>> do something wrong in our query).<br>
>><br>
>> If you have any ideas how to speed up virtual layers in QGIS it would be<br>
>> much appreciated.<br>
>><br>
>> Thanks,<br>
>> Andreas<br>
>><br>
>><br>
>> _______________________________________________<br>
>> QGIS-Developer mailing list<br>
>> <a href="mailto:QGIS-Developer@lists.osgeo.org" target="_blank">QGIS-Developer@lists.osgeo.org</a><br>
>> List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
>> Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
>><br>
> _______________________________________________<br>
> QGIS-Developer mailing list<br>
> <a href="mailto:QGIS-Developer@lists.osgeo.org" target="_blank">QGIS-Developer@lists.osgeo.org</a><br>
> List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
> Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
_______________________________________________<br>
QGIS-Developer mailing list<br>
<a href="mailto:QGIS-Developer@lists.osgeo.org" target="_blank">QGIS-Developer@lists.osgeo.org</a><br>
List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a></blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><font size="2"><font face="garamond, serif"><b>Ing. Salvatore Fiandaca</b><br><b>mobile</b>.:+39 327.493.8955 <br><b>m</b>: <b><a href="mailto:pigrecoinfinito@gmail.com" target="_blank">pig<span></span><span></span>recoinfinito@gmail.com</a></b></font></font></div><div><font face="garamond, serif" size="2"><b>C.F</b>.: FNDSVT71E29Z103G</font></div><div><font face="garamond, serif" size="2"><b>P.IVA</b>: 06597870820</font></div><div><font face="garamond, serif" size="2"><b>membro QGIS Italia - <a href="http://qgis.it/" target="_blank">http://qgis.it/</a></b><br><b>socio GFOSS.it - </b><a href="http://gfoss.it/" style="font-weight:bold" target="_blank">http://gfoss.it/</a></font></div><div><font face="garamond, serif" size="2"><b>blog:</b><b><a href="https://pigrecoinfinito.wordpress.com/" target="_blank"> https://pigrecoinfinito.wordpress.com/</a> <br>FB: Co-admin - <a href="https://www.facebook.com/qgis.it/" target="_blank">https://www.facebook.com/qgis.it/</a></b></font><b style="font-family:garamond,serif;font-size:small"><a href="https://www.facebook.com/qgis.it/" target="_blank"> </a> </b></div><div><b style="font-family:garamond,serif;font-size:small">TW:<a href="http://goog_95411464" target="_blank"> </a></b><font face="garamond, serif" size="2"><b><a href="https://twitter.com/totofiandaca" target="_blank">https://twitter.com/totofiandaca</a></b></font></div><div><font face="garamond, serif" size="2"><br></font></div><div dir="ltr"><font face="garamond, serif"><font size="2">43°51'0.54"N  10°34'27.62"E - EPSG:4326</font></font></div><div dir="ltr"><font face="garamond, serif"><font size="2"><br></font></font></div><div dir="ltr"><font face="garamond, serif"><font size="2">“Se la conoscenza deve essere aperta a tutti,</font></font></div><div dir="ltr"><font face="garamond, serif"><font size="2">perchè mai limitarne l’accesso?” </font></font></div><div dir="ltr"><font face="garamond, serif"><font size="2">R. Stallman<br><br></font></font><span style="font-family:"Trebuchet MS";font-size:10px">Questo documento, allegati inclusi, contiene informazioni di proprietà di FIANDACA SALVATORE e deve essere utilizzato esclusivamente dal destinatario in relazione alle finalità per le quali è stato ricevuto. E' vietata qualsiasi forma di riproduzione o divulgazione senza l'esplicito consenso di </span><span style="font-family:"Trebuchet MS";font-size:10px">FIANDACA SALVATORE</span><span style="font-family:"Trebuchet MS";font-size:10px">.</span><span style="font-family:"Trebuchet MS";font-size:10px"> Qualora fosse stato ricevuto per errore si prega di informare tempestivamente il mittente e distruggere la copia in proprio possesso.<br></span><font face="garamond, serif"><font size="2"><br><br></font></font></div><div dir="ltr"><font face="garamond, serif"><font size="2"></font></font></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div>