<div dir="ltr"><div>Hi,</div><div><br></div><div>  <span class="gmail-HwtZe" lang="en"><span class="gmail-jCAhz gmail-ChMk0b"><span class="gmail-ryNqvb">What I have noticed is that the virtual layer performance drop occurs only joining spatial tables in PostGIS.</span></span> <span class="gmail-jCAhz gmail-ChMk0b"><span class="gmail-ryNqvb">If the original tables do not contain geometry, or if they are stored in another format (I tried spatialite and shapefile) the performance is normal (a few seconds for an attributes join, output of 10,000 rows without geometry).</span></span></span></div><div><span class="gmail-HwtZe" lang="en"><span class="gmail-jCAhz gmail-ChMk0b"><span class="gmail-ryNqvb"><br></span></span></span></div><div><span class="gmail-HwtZe" lang="en"><span class="gmail-jCAhz gmail-ChMk0b"><span class="gmail-ryNqvb">  </span></span></span><span class="gmail-HwtZe" lang="en"><span class="gmail-jCAhz gmail-ChMk0b"><span class="gmail-ryNqvb">It also depends on the number of vertices of the source geometries (one second or less for an attributes join of PostGIS spatial tables, if the source geometries has only ten vertices). </span></span></span><span class="gmail-HwtZe" lang="en"><span class="gmail-jCAhz gmail-ChMk0b"><span class="gmail-ryNqvb">I have not yet tried trimming the decimal places of the vertex coordinates of the original geometries.</span></span></span></div><div><span class="gmail-HwtZe" lang="en"><span class="gmail-jCAhz gmail-ChMk0b"><span class="gmail-ryNqvb"><br></span></span></span></div><div><span class="gmail-HwtZe" lang="en"><span class="gmail-jCAhz gmail-ChMk0b"><span class="gmail-ryNqvb">  </span></span></span><span class="gmail-HwtZe" lang="en"><span class="gmail-jCAhz gmail-ChMk0b"><span class="gmail-ryNqvb">Despite the fact that the selection does not include the geometry of the original tables, a minute or more of high network traffic with the server and cpu usage is observed, as if the geometries resulting from the join of the features were fully scanned.</span></span></span></div><div><span class="gmail-HwtZe" lang="en"><span class="gmail-jCAhz gmail-ChMk0b"><span class="gmail-ryNqvb"> </span></span></span></div><div><span class="gmail-HwtZe" lang="en"><span class="gmail-jCAhz gmail-ChMk0b"><span class="gmail-ryNqvb"><br></span></span></span></div><div><span class="gmail-HwtZe" lang="en"><span class="gmail-jCAhz gmail-ChMk0b"><span class="gmail-ryNqvb">Regards,</span></span></span></div><div><span class="gmail-HwtZe" lang="en"><span class="gmail-jCAhz gmail-ChMk0b"><span class="gmail-ryNqvb">Gabriel <br></span></span></span></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">El vie, 19 may 2023 a la(s) 11:45, Alexandre Neto via QGIS-Developer (<a href="mailto:qgis-developer@lists.osgeo.org">qgis-developer@lists.osgeo.org</a>) escribió:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Hi,</div><div><br></div><div>I am trying to create a virtual layer that involves an attributes join between two layers. <br></div><div>something like this:</div><div><br></div><div>SELECT <br>  l.seg_via_rodov_id,<br>  l.via_rodov_id,<br>  vr.nome<br>FROM lig_segviarodov_viarodov as l,<br>  "Via rodoviária" as vr<br>where vr.identificador = l.via_rodov_id;<br><br></div><div>These two layer are saved in postgreSQL \ PostGIS and have and there's actually a foreign key constraint on .via_rodov_id referencing the vr.identificador.</div><div><br></div><div>As a virtual layer, this is painfully slow. Slow to the point of waiting 1 or 2 minutes to get the answer, while the same query on postgresql takes less than one second.</div><div><br></div><div>Not sure if this is expected or not or if it's a bug.<br></div><div><br></div><div>The reason I want to make this query as a virtual layer, instead of loading it as a postgresql query directly, is because I want to use this relation information in labels, and I wanted those labels to get updated before I save the data in the database (to help the editor to understand if a certain object is already updated or not)<br></div><div><br></div><div>I wonder if there's some workaround to help me with this.</div><div><br></div><div>Thanks</div><div><br></div><div>Alexandre Neto<br></div></div>
_______________________________________________<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>
</blockquote></div>