[Rt-commit] r14624 - rt/3.8/trunk/etc/upgrade
ruz at bestpractical.com
ruz at bestpractical.com
Tue Jul 29 16:21:56 EDT 2008
Author: ruz
Date: Tue Jul 29 16:21:55 2008
New Revision: 14624
Modified:
rt/3.8/trunk/etc/upgrade/shrink_cgm_table.pl
Log:
* make utility less memory hungry, load 1000 records at once
Modified: rt/3.8/trunk/etc/upgrade/shrink_cgm_table.pl
==============================================================================
--- rt/3.8/trunk/etc/upgrade/shrink_cgm_table.pl (original)
+++ rt/3.8/trunk/etc/upgrade/shrink_cgm_table.pl Tue Jul 29 16:21:55 2008
@@ -43,7 +43,8 @@
ENTRYAGGREGATOR => 'AND',
);
-while ( my $rec = $cgms->Next ) {
+FetchNext( $cgms, 'init' );
+while ( my $rec = FetchNext( $cgms ) ) {
$RT::Handle->BeginTransaction;
my ($status) = $rec->Delete;
unless ($status) {
@@ -53,3 +54,19 @@
$RT::Handle->Commit;
}
+use constant PAGE_SIZE => 1000;
+sub FetchNext {
+ my ($objs, $init) = @_;
+ if ( $init ) {
+ $objs->RowsPerPage( PAGE_SIZE );
+ $objs->FirstPage;
+ return;
+ }
+
+ my $obj = $objs->Next;
+ return $obj if $obj;
+ $objs->RedoSearch;
+ $objs->FirstPage;
+ return $objs->Next;
+}
+
More information about the Rt-commit
mailing list