[QGIS-Developer] Slow Joins on Virtual Layers

Alexandre Neto senhor.neto at gmail.com
Fri May 19 06:51:36 PDT 2023


Hi,

I am trying to create a virtual layer that involves an attributes join
between two layers.
something like this:

SELECT
  l.seg_via_rodov_id,
  l.via_rodov_id,
  vr.nome
FROM lig_segviarodov_viarodov as l,
  "Via rodoviária" as vr
where vr.identificador = l.via_rodov_id;

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.

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.

Not sure if this is expected or not or if it's a bug.

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)

I wonder if there's some workaround to help me with this.

Thanks

Alexandre Neto
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20230519/cf4a10fe/attachment.htm>


More information about the QGIS-Developer mailing list