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
  • Loading branch information
nyalldawson committed Nov 5, 2015
1 parent 8c86aab commit f0d31b03a9bbc1d43e1b51ccd4acf64cf2616a63
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 f0d31b0

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