Skip to content

Commit e3c1d18

Browse files
committedJan 4, 2019
[layouts] Fix inefficient filtering in attribute tables
Set the expression filter on the request itself, rather than looping through all features and testing on the filter. This allows providers to hand off the filtering to the underlying datasource, and utilise indices/etc where available. Fixes #20908
1 parent 899dcbf commit e3c1d18

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed
 

‎src/core/layout/qgslayoutitemattributetable.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,8 @@ bool QgsLayoutItemAttributeTable::getTableContents( QgsLayoutTableContents &cont
399399
QgsExpressionContext context = createExpressionContext();
400400
context.setFields( layer->fields() );
401401

402+
QgsFeatureRequest req;
403+
402404
//prepare filter expression
403405
std::unique_ptr<QgsExpression> filterExpression;
404406
bool activeFilter = false;
@@ -408,6 +410,7 @@ bool QgsLayoutItemAttributeTable::getTableContents( QgsLayoutTableContents &cont
408410
if ( !filterExpression->hasParserError() )
409411
{
410412
activeFilter = true;
413+
req.setFilterExpression( mFeatureFilter );
411414
}
412415
}
413416

@@ -431,8 +434,6 @@ bool QgsLayoutItemAttributeTable::getTableContents( QgsLayoutTableContents &cont
431434
}
432435
}
433436

434-
QgsFeatureRequest req;
435-
436437
if ( mSource == QgsLayoutItemAttributeTable::RelationChildren )
437438
{
438439
QgsRelation relation = mLayout->project()->relationManager()->relation( mRelationId );

0 commit comments

Comments
 (0)
Please sign in to comment.