Bug report #20018
Server and desktop too slow with Postgis views
|Affected QGIS version:||3.4.5||Regression?:||No|
|Operating System:||Windows||Easy fix?:||No|
|Pull Request or Patch supplied:||No||Resolution:|
|Crashes QGIS or corrupts data:||No||Copied to github as #:||27840|
If a layer is defined with a view or with sql, qgis issues a select distinct count of the id, I guess that it does that to assert that the Id is unique. If I have a huge table, it takes some 60 seconds to execute (and naively enough, multiply it if several layers are based on the same exact view) It causes timeouts in qgis server, and makes the map unusable. There should be a way to tell Qgis that I'm pretty sure that the PK is valid. Adding insult to injury, I don't even want to edit the data.
#4 Updated by Regis Haubourg over 1 year ago
- Status changed from Open to Feedback
Can you try the "trust dataprovider" option that is in the project properties / data source ? That should speed up loading times a lot since this option skips those consuming queries for views and datasources that don't have those metadata (extent, geometry type, id).
In my cases, with 250 big views in a project, the opening time went from 1min30s down to 4s . That was made on purpose for QGIS server use cases.