Skip to content

Commit

Permalink
Optimise adding many features to spatialite provider by avoiding
Browse files Browse the repository at this point in the history
unnecessary calculation of db uri for each feature

This adds significant overhead
  • Loading branch information
nyalldawson committed Feb 1, 2023
1 parent f5326af commit 50386c1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/providers/spatialite/qgsspatialiteprovider.cpp
Expand Up @@ -4148,6 +4148,8 @@ bool QgsSpatiaLiteProvider::addFeatures( QgsFeatureList &flist, Flags flags )
if ( flist.isEmpty() )
return true;

const QString logUri = uri( ).uri( false );

QgsAttributes attributevec = flist[0].attributes();

const QString savepointId { QStringLiteral( "qgis_spatialite_internal_savepoint_%1" ).arg( ++ sSavepointId ) };
Expand Down Expand Up @@ -4329,7 +4331,7 @@ bool QgsSpatiaLiteProvider::addFeatures( QgsFeatureList &flist, Flags flags )
ret = sqlite3_step( stmt );

char *expandedSql = sqlite3_expanded_sql( stmt );
QgsDatabaseQueryLogWrapper logWrapper( QString( expandedSql ), uri( ).uri( false ), QStringLiteral( "spatialite" ), QStringLiteral( "QgsSpatiaLiteProvider" ), QStringLiteral( "addFeatures" ) );
QgsDatabaseQueryLogWrapper logWrapper( QString( expandedSql ), logUri, QStringLiteral( "spatialite" ), QStringLiteral( "QgsSpatiaLiteProvider" ), QStringLiteral( "addFeatures" ) );
sqlite3_free( expandedSql );

sqlite3_finalize( stmt );
Expand Down

0 comments on commit 50386c1

Please sign in to comment.