
Hi everybody, According to my former mail about the Stats being too slow I implemented a caching mechanism (inspired by the caching in Kernel::System::Ticket::TicketGet()). As expected it reduced the time for the View-Subaction from about 60 to about 20 seconds. In my opinion 20 secs is still quite some time for a webpage to show up, but it's tolerable (and I don't know enough about the internal affairs of the stats to speed up stuff there ;) You find the patch at the end of my mail. I've got still the problem with the Edit mechanism though: * The first page (Subaction EditSpecification) takes about 25 secs. * The second page starts with Subaction Action which takes 20 secs itself but then redirects to another call with Subaction EditXaxis which takes another 50 secs. The resulting HTML page is so huge it takes my browser almost 2 minutes to render the page (Firefox hang when I tried to inspect the HTML with firebug ;). I think this is because of the huge amount of CustomerIDs presented in a select. Also because I do not use a persistent perl environment (mod_perl, FastCGI) my caching is lost between redirects (both EditSpecification and EditXaxis call StatsGet()). * third page: another redirect from Subaction Action to EditValueSeries takes about the same time. And also the huge HTML page with lots of CustomerIDs... *fouth page: Action redirects to EditRestrictions, lots of CustomerIDs, about 2:30 Any idea how I can exclude the CustomerIDs from the pages? Just a text input would be ok for me. (I've got 172260 different customer_user_id entries in table ticket). And what do you think of the patch? Greetings, gerhard --- Kernel/System/Stats.pm (2.4.6) +++ Kernel/System/Stats.pm (version with caching) @@ -251,6 +251,16 @@ return \%Stat if $Param{NoObjectAttributes}; + # caching Stats with ObjectAttributes + # we don not cache calls with $Param{NoObjectAttributes} or with !$Stat{Object} + # these do not take much time anyway + my $CacheKey = 'Cache::GetStats' . $Param{StatID}; + + # check if result is cached + if ( $Self->{$CacheKey} ) { + return $Self->{$CacheKey}; + } + KEY: for my $Key (qw(UseAsXvalue UseAsValueSeries UseAsRestriction)) { @@ -348,6 +358,9 @@ $Stat{$Key} = \@StatAttributesSimplified; } + # cache user result + $Self->{$CacheKey} = \%Stat; + return \%Stat; }
participants (1)
-
Gerhard Weber