Skip to content
Permalink
Browse files

Use a FilterFids request for vector file writer rather than fetching

all features and then testing the feature id when saving selected
features

For providers such as Postgres this is orders of magnitude faster.
Eg, saving 6 selected features from a 800k PostGIS table now
takes < 1 second as opposed to ~33 seconds

Fix #8334

(cherry-picked from f0d31b0)
  • Loading branch information
nyalldawson committed Nov 18, 2015
1 parent 14408d3 commit 57381f490b54e83474cc2c65142787702e924c2d
Showing with 2 additions and 5 deletions.
  1. +2 −5 src/core/qgsvectorfilewriter.cpp
@@ -1982,10 +1982,10 @@ QgsVectorFileWriter::WriterError QgsVectorFileWriter::writeAsVectorFormat( QgsVe
req.setFlags( QgsFeatureRequest::NoGeometry );
}
req.setSubsetOfAttributes( allAttr );
if ( onlySelected )
req.setFilterFids( layer->selectedFeaturesIds() );
QgsFeatureIterator fit = layer->getFeatures( req );

const QgsFeatureIds& ids = layer->selectedFeaturesIds();

//create symbol table if needed
if ( writer->symbologyExport() != NoSymbology )
{
@@ -2027,9 +2027,6 @@ QgsVectorFileWriter::WriterError QgsVectorFileWriter::writeAsVectorFormat( QgsVe
// write all features
while ( fit.nextFeature( fet ) )
{
if ( onlySelected && !ids.contains( fet.id() ) )
continue;

if ( shallTransform )
{
try

0 comments on commit 57381f4

Please sign in to comment.
You can’t perform that action at this time.