Skip to content
Permalink
Browse files

[postgres] Early exit iterator if there's nothing to fetch anyway

  • Loading branch information
m-kuhn committed Oct 25, 2017
1 parent a8caf49 commit 62f2091383f43837bb968b574964aa41af5b5ad2
Showing with 10 additions and 14 deletions.
  1. +10 −14 src/providers/postgres/qgspostgresfeatureiterator.cpp
@@ -36,6 +36,13 @@ QgsPostgresFeatureIterator::QgsPostgresFeatureIterator( QgsPostgresFeatureSource
, mLastFetch( false )
, mFilterRequiresGeometry( false )
{
if ( request.filterType() == QgsFeatureRequest::FilterFids && request.filterFids().isEmpty() )
{
mClosed = true;
iteratorClosed();
return;
}

if ( !source->mTransactionConnection )
{
mConn = QgsPostgresConnPool::instance()->acquireConnection( mSource->mConnInfo );
@@ -65,8 +72,7 @@ QgsPostgresFeatureIterator::QgsPostgresFeatureIterator( QgsPostgresFeatureSource
catch ( QgsCsException & )
{
// can't reproject mFilterRect
mClosed = true;
iteratorClosed();
close();
return;
}

@@ -96,17 +102,9 @@ QgsPostgresFeatureIterator::QgsPostgresFeatureIterator( QgsPostgresFeatureSource
}
else if ( request.filterType() == QgsFeatureRequest::FilterFids )
{
if ( request.filterFids().isEmpty() )
{
mClosed = true;
iteratorClosed();
}
else
{
QString fidsWhereClause = QgsPostgresUtils::whereClause( mRequest.filterFids(), mSource->mFields, mConn, mSource->mPrimaryKeyType, mSource->mPrimaryKeyAttrs, mSource->mShared );
QString fidsWhereClause = QgsPostgresUtils::whereClause( mRequest.filterFids(), mSource->mFields, mConn, mSource->mPrimaryKeyType, mSource->mPrimaryKeyAttrs, mSource->mShared );

whereClause = QgsPostgresUtils::andWhereClauses( whereClause, fidsWhereClause );
}
whereClause = QgsPostgresUtils::andWhereClauses( whereClause, fidsWhereClause );
}
else if ( request.filterType() == QgsFeatureRequest::FilterExpression )
{
@@ -237,8 +235,6 @@ QgsPostgresFeatureIterator::QgsPostgresFeatureIterator( QgsPostgresFeatureSource
if ( !success )
{
close();
mClosed = true;
iteratorClosed();
}
}

0 comments on commit 62f2091

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