Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Data Model Questions /

SSViewer::process is extremely slow


Reply


906 Views

Avatar
joern

Community Member, 28 Posts

13 May 2011 at 5:45am

Hi,
I have a summary page that displays my records. (currently 100 entries. Each record has some relations)

I cache the query with my own key (getRecordsCacheKey()).

My main function of the records is:

      $options = $this->getRecordOptions();
      $cachekey = $this->RecordsCacheKey($count);
      $cache = SS_Cache::factory($cachekey);
      $result = $cache->load($cachekey);
      
      if ($result) {
         return unserialize($result);
      }
      
      // get all records
      $options['limit'] = $count ? '' : $options['limit'];
      
      $recordSet = DataObject::get(
         'Record',
         "`SiteTree`.`ParentID` = '".$this->ID."'{$options['filter']}",
         'Created DESC',
         "{$options['join']}",
         $options['limit']
      );
      
      if (!$count) {
         if (!$recordSet || !$recordSet->exists()) {
            $recordSet = false;
         }
         else {
            // add controller
            foreach ($recordSet as $record) {
               if (!$record->controller) {
                  $record->controller = ModelAsController::controller_for($record);
               }
            }
         }
      }
         
      $cache->save(serialize($recordSet));
         
      return $recordSet;

Do you have any ideas why this is so slow?
I have a grid server at Media Temple.

The profiler gives me back the following data:

============================================================================
PROFILER OUTPUT
============================================================================
Calls Time Routine
-----------------------------------------------------------------------------
2 6281.3482 ms (91.38 %) SSViewer::process
1 300.3595 ms (4.37 %) all_execution
254 57.8549 ms (0.84 %) obj.CurrentMember
180 37.4069 ms (0.54 %) obj.RelationshipAggregate
1 31.8980 ms (0.46 %) obj.getRecordPages
1 28.3639 ms (0.41 %) DB::connect
289 20.9572 ms (0.30 %) obj.ID
294 20.7319 ms (0.30 %) obj.LastEdited
6 20.3063 ms (0.30 %) obj.Link
1 7.7510 ms (0.11 %) main.php init
1 6.5000 ms (0.09 %) obj.Menu
2 4.7660 ms (0.07 %) obj.Page
72 4.6082 ms (0.07 %) obj.Max
2 4.5030 ms (0.07 %) Requirements::includeInHTML
4 3.1075 ms (0.05 %) obj.LinkingMode
5 0.9570 ms (0.01 %) obj.Title
1 0.6990 ms (0.01 %) obj.Browser
4 0.5200 ms (0.01 %) obj.MenuTitle
3 0.3159 ms (0.00 %) obj.SiteConfig
1 0.3150 ms (0.00 %) obj.ListLink
1 0.3140 ms (0.00 %) obj.MetaTags
1 0.2222 ms (0.00 %) obj.LightTableLink
1 0.2060 ms (0.00 %) obj.MapLink
1 0.1779 ms (0.00 %) obj.OS
2 0.1631 ms (0.00 %) obj.CurrentPageCount
1 0.1490 ms (0.00 %) obj.getItemsPerPage
1 0.1059 ms (0.00 %) obj.title_seperator
1 0.0880 ms (0.00 %) obj.Layout
2 0.0501 ms (0.00 %) obj.Results
1 0.0291 ms (0.00 %) unprofiled

39.3982 ms (0.57 %) Missed
============================================================================
6874.1729 ms (100.00 %) OVERALL TIME
============================================================================

and after a ?flush=all

============================================================================
PROFILER OUTPUT
============================================================================
Calls Time Routine
-----------------------------------------------------------------------------
2 31863.5373 ms (63.16 %) SSViewer::process
36 12478.1561 ms (24.73 %) obj.explore
1 4232.0690 ms (8.39 %) all_execution
36 395.6869 ms (0.78 %) obj.Comments
22 326.2243 ms (0.65 %) obj.isCompared
2 251.8079 ms (0.50 %) SSViewer::process - compile
22 219.4819 ms (0.44 %) obj.isLiked
36 67.5836 ms (0.13 %) obj.Images
108 58.4056 ms (0.12 %) obj.Location
22 46.3500 ms (0.09 %) obj.LikeURL
180 44.3790 ms (0.09 %) obj.RelationshipAggregate
127 40.5979 ms (0.08 %) obj.Link
14 34.0087 ms (0.07 %) obj.Tags
20 29.0589 ms (0.06 %) obj.Specifications
1 28.9550 ms (0.06 %) obj.getRecordPages
22 28.4653 ms (0.06 %) obj.CompareURL
286 27.8792 ms (0.06 %) obj.CurrentMember
6 24.8339 ms (0.05 %) obj.ProfileLink
294 22.1984 ms (0.04 %) obj.LastEdited
2 14.3023 ms (0.03 %) obj.Page
105 13.6571 ms (0.03 %) obj.Title
289 12.5902 ms (0.02 %) obj.ID
2 10.3981 ms (0.02 %) Requirements::includeInHTML
2 8.9550 ms (0.02 %) obj.getCompareCount
1 7.7150 ms (0.02 %) DB::connect
36 6.6502 ms (0.01 %) obj.Content
36 6.0768 ms (0.01 %) obj.URL
24 5.6708 ms (0.01 %) obj.CharactersLink
36 5.4355 ms (0.01 %) obj.Lng
1 5.3539 ms (0.01 %) obj.Menu
36 4.8487 ms (0.01 %) obj.Lat
51 4.2641 ms (0.01 %) obj.ATT
36 4.2412 ms (0.01 %) obj.output_count
88 3.4630 ms (0.01 %) obj.controller
36 3.4049 ms (0.01 %) obj.LimitCharacters
51 3.3996 ms (0.01 %) obj.Last
36 3.3753 ms (0.01 %) obj.FormatedAddress
22 3.1412 ms (0.01 %) obj.canEdit
4 3.0801 ms (0.01 %) obj.LinkingMode
36 2.2240 ms (0.00 %) obj.Count
24 2.0540 ms (0.00 %) obj.Characters
36 0.9942 ms (0.00 %) obj.First
1 0.8130 ms (0.00 %) obj.Browser
1 0.7513 ms (0.00 %) main.php init
6 0.6390 ms (0.00 %) obj.SiteConfig
23 0.5593 ms (0.00 %) obj.canCompareRecords
4 0.5009 ms (0.00 %) obj.MenuTitle
2 0.3881 ms (0.00 %) obj.InSection
1 0.3331 ms (0.00 %) obj.MetaTags
1 0.3080 ms (0.00 %) obj.ListLink
1 0.2460 ms (0.00 %) obj.LightTableLink
2 0.2451 ms (0.00 %) obj.BaseHref
1 0.2010 ms (0.00 %) obj.MapLink
2 0.1979 ms (0.00 %) obj.canDebug
1 0.1888 ms (0.00 %) obj.OS
2 0.1650 ms (0.00 %) obj.CurrentPageCount
1 0.1550 ms (0.00 %) obj.getItemsPerPage
1 0.1199 ms (0.00 %) obj.title_seperator
1 0.1111 ms (0.00 %) obj.Layout
2 0.0491 ms (0.00 %) obj.Results
1 0.0179 ms (0.00 %) unprofiled

91.0802 ms (0.18 %) Missed
============================================================================
50452.0440 ms (100.00 %) OVERALL TIME
============================================================================