[QGIS-Developer] Feature count for DB provider.

Rémi Desgrange remi.desgrange at ielo.net
Sat Jun 25 01:38:01 PDT 2022


Hi,

Just launched the new QGIS 3.24, and tests the SQL debugger, I just found out that the “feature count” does a while loop on all features in the layer to count.

While it’s probably necessary for shapefiles or stuff like that, it appears suboptimal for databases access. I found this part in the code that looks like to be responsible for the feature counts, https://github.com/qgis/QGIS/blob/master/src/core/vector/qgsvectorlayerfeaturecounter.cpp#L76-L90

Do you think I could make a special case for database-based provider (geopackage, postgres/oracle/mysql/etc…) that launch a “SELECT count(*) FROM table” instead of looping on all features.

Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20220625/f2143d57/attachment.htm>


More information about the QGIS-Developer mailing list