[Rt-commit] rt branch, 4.2/faster-database-size-estimates, created. rt-4.1.6-277-g4e9b168

Thomas Sibley trs at bestpractical.com
Thu Feb 21 13:41:15 EST 2013


The branch, 4.2/faster-database-size-estimates has been created
        at  4e9b1688afdd781c5eabd96521f1ab57f8ab934c (commit)

- Log -----------------------------------------------------------------
commit 382a1ce25a04f68706a54857509be7137029adde
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Thu Feb 21 10:34:26 2013 -0800

    Count disabled rows in "RT size" estimation
    
    They're still present in the database.  Excluding them may drastically
    mislead about the size of groups, for example.

diff --git a/share/html/Admin/Tools/Configuration.html b/share/html/Admin/Tools/Configuration.html
index d723d88..71d1702 100644
--- a/share/html/Admin/Tools/Configuration.html
+++ b/share/html/Admin/Tools/Configuration.html
@@ -150,6 +150,7 @@ for my $type (qw/Tickets Queues Transactions Groups PrivilegedUsers Unprivileged
     $class =~ s/Privileged|Unprivileged//;
     my $collection = $class->new(RT->SystemUser);
     $collection->UnLimit;
+    $collection->FindAllRows;   # find disabled
     if ($type =~ /PrivilegedUsers/) {
         $user_count = $collection->CountAll;
         $collection->LimitToPrivileged;

commit 4e9b1688afdd781c5eabd96521f1ab57f8ab934c
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Wed Feb 20 12:16:17 2013 -0800

    Estimate RT size much more quickly by calculating id ranges
    
    Counting tickets, transactions, and groups can take quite a long time on
    very large databases.  Reduce our fully accurate count to a pretty good
    estimate by calculating the range of id values instead.  The min and max
    functions can use the primary key indexes to return quick results.
    
    Using the range accounts for instances where the starting ticket ID was
    bumped higher for aesthetic or recovery reasons.  It will overestimate
    size if there are significant gaps in the id sequence, however.

diff --git a/share/html/Admin/Tools/Configuration.html b/share/html/Admin/Tools/Configuration.html
index 71d1702..16447a4 100644
--- a/share/html/Admin/Tools/Configuration.html
+++ b/share/html/Admin/Tools/Configuration.html
@@ -151,6 +151,7 @@ for my $type (qw/Tickets Queues Transactions Groups PrivilegedUsers Unprivileged
     my $collection = $class->new(RT->SystemUser);
     $collection->UnLimit;
     $collection->FindAllRows;   # find disabled
+    $collection->OrderBy();     # clear order by
     if ($type =~ /PrivilegedUsers/) {
         $user_count = $collection->CountAll;
         $collection->LimitToPrivileged;
@@ -158,7 +159,13 @@ for my $type (qw/Tickets Queues Transactions Groups PrivilegedUsers Unprivileged
     } elsif ($type =~ /UnprivilegedUsers/) {
         $count = $user_count - $privileged_count;
     } else {
-        $count = $collection->CountAll;
+        my $range  = $collection->Column( FIELD => "id", FUNCTION => "max(?) - min(?)" );
+        my $result = $collection->First;
+        if ($result) {
+            $count = loc("[_1] (id range)", $result->__Value($range));
+        } else {
+            $count = loc("error calculating the range");
+        }
     }
     $index_size++;
 </%PERL>

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


More information about the Rt-commit mailing list