[Rt-commit] rt branch, 4.2/who-have-right-optimization, created. rt-4.2.2-10-gefc3631

Alex Vandiver alexmv at bestpractical.com
Thu Jan 30 14:50:21 EST 2014


The branch, 4.2/who-have-right-optimization has been created
        at  efc3631b5b88d4d27b5a096a96a7e7cb88abb6ea (commit)

- Log -----------------------------------------------------------------
commit 4621dfeadc3f47175287e7325c254f4b1f55497b
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Thu Jan 30 14:47:35 2014 -0500

    Push the RT::System object, so its ->id is used in WhoHaveGroupRight
    
    This allows better use of indexes, as we have both an ObjectId and an ObjectType

diff --git a/lib/RT/Users.pm b/lib/RT/Users.pm
index a3eccf3..754fa25 100644
--- a/lib/RT/Users.pm
+++ b/lib/RT/Users.pm
@@ -362,7 +362,7 @@ sub _GetEquivObjects
     }
 
     if( $args{'IncludeSystemRights'} ) {
-        push @objects, 'RT::System';
+        push @objects, $RT::System;
     }
     push @objects, @{ $args{'EquivObjects'} };
     return grep $_, @objects;

commit efc3631b5b88d4d27b5a096a96a7e7cb88abb6ea
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Thu Jan 30 14:48:59 2014 -0500

    De-duplicate ACLEquiv objects in WhoHaveGroupRight
    
    While this not only makes the generated query somewhat cleaner, in at
    least one case the presence of duplicates caused Postgres 9.3 to
    generate a massively sub-optimal query plan; removing the duplicate
    clauses resolved the issue.

diff --git a/lib/RT/Users.pm b/lib/RT/Users.pm
index 754fa25..f53ca80 100644
--- a/lib/RT/Users.pm
+++ b/lib/RT/Users.pm
@@ -504,12 +504,14 @@ sub WhoHaveGroupRight
     my ($check_objects) = ('');
     my @objects = $self->_GetEquivObjects( %args );
 
+    my %seen;
     if ( @objects ) {
         my @object_clauses;
         foreach my $obj ( @objects ) {
             my $type = ref($obj)? ref($obj): $obj;
-            my $id;
+            my $id = 0;
             $id = $obj->id if ref($obj) && UNIVERSAL::can($obj, 'id') && $obj->id;
+            next if $seen{"$type-$id"}++;
 
             my $object_clause = "$acl.ObjectType = '$type'";
             $object_clause   .= " AND $acl.ObjectId   = $id" if $id;

-----------------------------------------------------------------------


More information about the rt-commit mailing list