Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Mark common postgresql types as non-enumerable upon load
This fixes a big performance issue when loading projects with PostgreSQL layers.
In the last stage of project loading, code in QgisApp would run code
to resolve broken layer dependencies, which in turn tried to find out best
edit widget for all columns of all layers, and the enumeration widget tried
to figure out all enum values, doing two SQL calls for each column for each layer.

We know what are types of columns when loading a layer, so enumValues() can leave
early without doing the excessive queries when it's not necessary.

Testing on a real world QGIS project with 300+ layers (but not all PostgreSQL):
- before: ~35 minutes to load / ~8K PostgreSQL queries
- after: ~10 minutes to load / ~2K PostgreSQL queries
  • Loading branch information
wonder-sk authored and github-actions[bot] committed May 18, 2023
1 parent e7c8417 commit c53000e
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/providers/postgres/qgspostgresprovider.cpp
Expand Up @@ -1388,6 +1388,11 @@ bool QgsPostgresProvider::loadFields()

mIdentityFields.insert( mAttributeFields.size(), identityMap[tableoid][attnum][0].toLatin1() );
mAttributeFields.append( newField );

// if we know for sure that this field is not enumerated type or a domain type, let's
// mark it here, so that enumValues() does not need to check it again (for types like int, text, ...)
if ( fieldTType != QLatin1String( "e" ) && !isDomain )
mShared->setFieldSupportsEnumValues( fields.count() - 1, false );
}

setEditorWidgets();
Expand Down

0 comments on commit c53000e

Please sign in to comment.