[Rt-commit] rt branch, 4.2/who-have-right-optimization, repushed
Alex Vandiver
alexmv at bestpractical.com
Fri May 8 16:31:11 EDT 2015
The branch 4.2/who-have-right-optimization was deleted and repushed:
was 5f039853573bcaaf58d33a59634f289d26066898
now 9f96a81abd067c8630cc4c887abfb03696bf69fe
1: 2552c79 = 1: 8cb2dc5 Only add limits for types that explicitly are rights targets
2: 5f03985 ! 2: 9f96a81 Simplify WhoHaveRoleRight and WhoHaveGroupRight queries before unioning
@@ -15,6 +15,51 @@
This does come at the assumption that duplicates within each of the two
queries are not common -- that is, that users will not have the relevant
right by way of a large number of membership paths.
+
+diff --git a/lib/RT/Groups.pm b/lib/RT/Groups.pm
+--- a/lib/RT/Groups.pm
++++ b/lib/RT/Groups.pm
+@@
+ EquivObjects => [ ],
+ @_ );
+
++ my @ids = (0);
++
+ my $from_role = $self->Clone;
+ $from_role->WithRoleRight( %args );
++ $from_role->Columns( 'id' );
++ $from_role->OrderBy();
++ $from_role->{'joins_are_distinct'} = 1;
++ while (my $row = $from_role->Next) {
++ push @ids, $row->id;
++ }
+
+ my $from_group = $self->Clone;
+ $from_group->WithGroupRight( %args );
++ $from_group->Columns( 'id' );
++ $from_group->OrderBy();
++ $from_group->{'joins_are_distinct'} = 1;
++ while (my $row = $from_group->Next) {
++ push @ids, $row->id;
++ }
+
+- #XXX: DIRTY HACK
+- use DBIx::SearchBuilder::Union;
+- my $union = DBIx::SearchBuilder::Union->new();
+- $union->add($from_role);
+- $union->add($from_group);
++ my $union = RT::Groups->new( $self->CurrentUser );
++ while ( @ids > 1000 ) {
++ my @batch = splice( @ids, 0, 1000 );
++ $union->Limit( FIELD => 'id', OPERATOR => 'IN', VALUE => \@batch );
++ }
++ $union->Limit( FIELD => 'id', OPERATOR => 'IN', VALUE => \@ids );
++ $union->{'handled_disabled_column'} = 1;
+ %$self = %$union;
+- bless $self, ref($union);
+
+ return;
+ }
diff --git a/lib/RT/Users.pm b/lib/RT/Users.pm
--- a/lib/RT/Users.pm
@@ -49,6 +94,10 @@
- $union->add( $from_group );
- $union->add( $from_role );
+ my $union = RT::Users->new( $self->CurrentUser );
++ while ( @ids > 1000 ) {
++ my @batch = splice( @ids, 0, 1000 );
++ $union->Limit( FIELD => 'id', OPERATOR => 'IN', VALUE => \@batch );
++ }
+ $union->Limit( FIELD => 'id', OPERATOR => 'IN', VALUE => \@ids );
+ $union->{'handled_disabled_column'} = 1;
%$self = %$union;
More information about the rt-commit
mailing list