Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[postgres] Really disable dynamic queue size
The original commit speed up some layers, but regressed
performance for others. It was decided to revert the
dynamic queue feature, but it seems this was never actually
done.

Fixes #16239, #19203
  • Loading branch information
nyalldawson committed Jun 16, 2018
1 parent 8323462 commit ce74d57
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
11 changes: 4 additions & 7 deletions src/providers/postgres/qgspostgresfeatureiterator.cpp
Expand Up @@ -28,13 +28,6 @@

QgsPostgresFeatureIterator::QgsPostgresFeatureIterator( QgsPostgresFeatureSource *source, bool ownSource, const QgsFeatureRequest &request )
: QgsAbstractFeatureIteratorFromSource<QgsPostgresFeatureSource>( source, ownSource, request )
, mFeatureQueueSize( 1 )
, mFetched( 0 )
, mFetchGeometry( false )
, mExpressionCompiled( false )
, mOrderByCompiled( false )
, mLastFetch( false )
, mFilterRequiresGeometry( false )
{
if ( request.filterType() == QgsFeatureRequest::FilterFids && request.filterFids().isEmpty() )
{
Expand Down Expand Up @@ -260,8 +253,10 @@ bool QgsPostgresFeatureIterator::fetchFeature( QgsFeature &feature )

if ( mFeatureQueue.empty() && !mLastFetch )
{
#if 0 //disabled dynamic queue size
QElapsedTimer timer;
timer.start();
#endif

QString fetch = QStringLiteral( "FETCH FORWARD %1 FROM %2" ).arg( mFeatureQueueSize ).arg( mCursorName );
QgsDebugMsgLevel( QString( "fetching %1 features." ).arg( mFeatureQueueSize ), 4 );
Expand Down Expand Up @@ -299,6 +294,7 @@ bool QgsPostgresFeatureIterator::fetchFeature( QgsFeature &feature )
}
unlock();

#if 0 //disabled dynamic queue size
if ( timer.elapsed() > 500 && mFeatureQueueSize > 1 )
{
mFeatureQueueSize /= 2;
Expand All @@ -307,6 +303,7 @@ bool QgsPostgresFeatureIterator::fetchFeature( QgsFeature &feature )
{
mFeatureQueueSize *= 2;
}
#endif
}

if ( mFeatureQueue.empty() )
Expand Down
14 changes: 7 additions & 7 deletions src/providers/postgres/qgspostgresfeatureiterator.h
Expand Up @@ -102,13 +102,13 @@ class QgsPostgresFeatureIterator : public QgsAbstractFeatureIteratorFromSource<Q
QQueue<QgsFeature> mFeatureQueue;

//! Maximal size of the feature queue
int mFeatureQueueSize;
int mFeatureQueueSize = 2000;

//! Number of retrieved features
int mFetched;
int mFetched = 0;

//! Sets to true, if geometry is in the requested columns
bool mFetchGeometry;
bool mFetchGeometry = false;

bool mIsTransactionConnection = false;

Expand All @@ -119,10 +119,10 @@ class QgsPostgresFeatureIterator : public QgsAbstractFeatureIteratorFromSource<Q
inline void lock();
inline void unlock();

bool mExpressionCompiled;
bool mOrderByCompiled;
bool mLastFetch;
bool mFilterRequiresGeometry;
bool mExpressionCompiled = false;
bool mOrderByCompiled = false;
bool mLastFetch = false;
bool mFilterRequiresGeometry = false;

QgsCoordinateTransform mTransform;
QgsRectangle mFilterRect;
Expand Down

0 comments on commit ce74d57

Please sign in to comment.