<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <p>Hi,</p>
    <p>One of my colleagues created a QGIS project where they loaded a
      parcel layer with approx. 24000 polygons (data source Postgis) and
      another layer with 3 polygons representing project perimeters of
      contruction sites. That second layer is in a Geopackage.<br>
    </p>
    <p>Now they want to select all parcels that are intersecting the
      project perimeters.</p>
    <p>The query is straightforward:</p>
    <p><tt><span style="font-size: 10pt;">SELECT lie.nummer_grundstueck,
          lie.gemeinde, tbap.bemerkungen, lie.geometry</span></tt><tt><span
          style="font-size: 10pt;" lang="EN-US"><br>
          FROM lie_liegenschaft lie, tba_projektperimeter tbap<br>
          WHERE ST_Intersects(lie.geometry, tbap.geometry)</span></tt></p>
    <p><span style="font-size: 10pt;" lang="EN-US">Now the problem is:
        this query (24000 parcels, 3 project perimeters) is just
        incredibly slow: about 40 seconds. In a Postgis view this would
        be way less then a second! The worst thing: that virtual layer
        is updated with each and every zoom and pan. Is there no way to
        cache a virtual layer?</span></p>
    <p><span style="font-size: 10pt;" lang="EN-US">Can I do something to
        speed up our virtual layer? The parcel layer only chanes once a
        month and the perimeters only occasionally, so it would be best
        to cache the result within a QGIS session, because there are no
        changes in the geometries of both layers expected.</span></p>
    <p><span style="font-size: 10pt;" lang="EN-US">I understand that
        virtual layers somehow have to transfer all data formats
        (through ogr) into SpatiaLite or SQLite to do the query, but
        this is really way too slow for real world usage in my opinion
        (unless I do something wrong in our query).</span></p>
    <p><span style="font-size: 10pt;" lang="EN-US">If you have any ideas
        how to speed up virtual layers in QGIS it would be much
        appreciated.</span></p>
    <p><span style="font-size: 10pt;" lang="EN-US">Thanks,<br>
        Andreas<br>
      </span></p>
    <span
style="font-size:10.0pt;font-family:"Arial","sans-serif""
      lang="EN-US"></span>
  </body>
</html>