Skip to content

Commit ce74d57

Browse files
committed
[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
1 parent 8323462 commit ce74d57

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

src/providers/postgres/qgspostgresfeatureiterator.cpp

+4-7
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,6 @@
2828

2929
QgsPostgresFeatureIterator::QgsPostgresFeatureIterator( QgsPostgresFeatureSource *source, bool ownSource, const QgsFeatureRequest &request )
3030
: QgsAbstractFeatureIteratorFromSource<QgsPostgresFeatureSource>( source, ownSource, request )
31-
, mFeatureQueueSize( 1 )
32-
, mFetched( 0 )
33-
, mFetchGeometry( false )
34-
, mExpressionCompiled( false )
35-
, mOrderByCompiled( false )
36-
, mLastFetch( false )
37-
, mFilterRequiresGeometry( false )
3831
{
3932
if ( request.filterType() == QgsFeatureRequest::FilterFids && request.filterFids().isEmpty() )
4033
{
@@ -260,8 +253,10 @@ bool QgsPostgresFeatureIterator::fetchFeature( QgsFeature &feature )
260253

261254
if ( mFeatureQueue.empty() && !mLastFetch )
262255
{
256+
#if 0 //disabled dynamic queue size
263257
QElapsedTimer timer;
264258
timer.start();
259+
#endif
265260

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

297+
#if 0 //disabled dynamic queue size
302298
if ( timer.elapsed() > 500 && mFeatureQueueSize > 1 )
303299
{
304300
mFeatureQueueSize /= 2;
@@ -307,6 +303,7 @@ bool QgsPostgresFeatureIterator::fetchFeature( QgsFeature &feature )
307303
{
308304
mFeatureQueueSize *= 2;
309305
}
306+
#endif
310307
}
311308

312309
if ( mFeatureQueue.empty() )

src/providers/postgres/qgspostgresfeatureiterator.h

+7-7
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,13 @@ class QgsPostgresFeatureIterator : public QgsAbstractFeatureIteratorFromSource<Q
102102
QQueue<QgsFeature> mFeatureQueue;
103103

104104
//! Maximal size of the feature queue
105-
int mFeatureQueueSize;
105+
int mFeatureQueueSize = 2000;
106106

107107
//! Number of retrieved features
108-
int mFetched;
108+
int mFetched = 0;
109109

110110
//! Sets to true, if geometry is in the requested columns
111-
bool mFetchGeometry;
111+
bool mFetchGeometry = false;
112112

113113
bool mIsTransactionConnection = false;
114114

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

122-
bool mExpressionCompiled;
123-
bool mOrderByCompiled;
124-
bool mLastFetch;
125-
bool mFilterRequiresGeometry;
122+
bool mExpressionCompiled = false;
123+
bool mOrderByCompiled = false;
124+
bool mLastFetch = false;
125+
bool mFilterRequiresGeometry = false;
126126

127127
QgsCoordinateTransform mTransform;
128128
QgsRectangle mFilterRect;

0 commit comments

Comments
 (0)