Skip to content
Permalink
Browse files

Fix slow PG raster SRID identify

Reading all raster rows is too slow, by querying
raster_columns we can retrieve the SRID directly.

Fixes #33885
  • Loading branch information
elpaso committed Jan 21, 2020
1 parent ccc7ad5 commit 1c486dcfaa5b130f4e6a49a5e49338fff28fe7e9
Showing with 8 additions and 6 deletions.
  1. +8 −6 src/providers/postgres/qgspostgresconn.cpp
@@ -1686,12 +1686,14 @@ void QgsPostgresConn::retrieveLayerTypes( QVector<QgsPostgresLayerProperty *> &l

if ( layerProperty.isRaster )
{
QString sql = QStringLiteral( "SELECT %3, "
"array_agg(DISTINCT ST_SRID( %1 ) || ':RASTER')"
" FROM %2" )
.arg( quotedIdentifier( layerProperty.geometryColName ) )
.arg( table )
.arg( i - 1 );
const QString sql = QStringLiteral( "SELECT %1, "
"array_agg( srid || ':RASTER') "
"FROM raster_columns "
"WHERE r_raster_column = %2 AND r_table_schema = %3 AND r_table_name = %4" )
.arg( i - 1 )
.arg( quotedValue( layerProperty.geometryColName ) )
.arg( quotedValue( layerProperty.schemaName ) )
.arg( quotedValue( layerProperty.tableName ) );

QgsDebugMsg( "Raster srids query: " + sql );
query += sql;

0 comments on commit 1c486dc

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