Limit user in a perl script

Hi!
I try to search for users with no connections to any ticket and no
connection to any attachments to delete them later.

I can’t use rt-shredder directly :wink:

I try this:


my $user = RT::User->new($RT::SystemUser);
my $users = RT::Users->new($RT::SystemUser);
my $tix = RT::Tickets->new($RT::SystemUser);

$users->FindAllRows ;

while (my $uid = $users->next ) {
my $tickets = RT::Tickets->new($RT::SystemUser);
$user->Load($uid);
$tickets->FromSQL(‘
Type = “ticket” AND
Watcher ="’.$user->EmailAddress.’"’);

Delete_User if ! $tickets->Count();

But takes much time (about 10s per user ) in my system for every user.

~500.000 tickets
~ 61.100 users

Is there a better method to limit the user with no tickets and no
attachments?

Cheers,
Bj�rn