Changeset 1334

Show
Ignore:
Timestamp:
03/13/08 00:48:02 (7 months ago)
Author:
benoitg
Message:
  • Major performance improvement in content manager for content groups picking items with limits on how many times they can be displayed.
    • Improve performance of Content::getLastDisplayedTimestamp(), will mostly show when using the RSS aggregator, especially when postgres has little memory
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wifidog-auth/CHANGELOG

    r1331 r1334  
    11# $Id$ 
     22008-03-12 Benoit GrĂ©goire  <bock@step.polymtl.ca> 
     3    * Major performance improvement in content manager for content groups picking items with limits on how many times they can be displayed. 
     4        * Improve performance of Content::getLastDisplayedTimestamp(), will mostly show when using the RSS aggregator, especially when postgres has little memory 
     5         
    262008-03-06 Benoit GrĂ©goire  <bock@step.polymtl.ca> 
    37    * Fix #438.  Not Node::getNumOnlineUsers() will count every users connected (once for every account), except the splash-only user + every mac adresses connecting as the splash-only user. 
  • trunk/wifidog-auth/wifidog/classes/Content.php

    r1308 r1334  
    14341434        $db = AbstractDb :: getObject(); 
    14351435 
    1436         $sql = "SELECT EXTRACT('epoch' FROM last_display_timestamp) as last_display_timestamp FROM content_display_log WHERE content_id='$this->id' $user_sql $node_sql ORDER BY last_display_timestamp DESC limit 1"; 
     1436        $sql = "SELECT EXTRACT('epoch' FROM MAX(last_display_timestamp)) as last_display_timestamp FROM content_display_log WHERE content_id='$this->id' $user_sql $node_sql"; 
    14371437        $db->execSqlUniqueRes($sql, $log_row, false); 
    14381438        if ($log_row != null) { 
     
    15231523                array ( 
    15241524                'isSimpleContent' 
    1525                        
     1525               
    15261526                ); 
    15271527                $metadada_allowed_content_types = ContentTypeFilter :: getObject($criteria_array); 
     
    19701970            'title' => _("Reusable content library"), 
    19711971            'url' => BASE_URL_PATH.htmlspecialchars("admin/generic_object_admin.php?object_class=Content&action=list") 
    1972                ); 
     1972            ); 
    19731973        } 
    19741974 
  • trunk/wifidog-auth/wifidog/classes/Content/ContentGroup/ContentGroup.php

    r1320 r1334  
    495495                /* There aren't enough elements to redisplay, We need new content */ 
    496496 
    497                 $sql_base = "SELECT content_group_element_id FROM content_group_element WHERE content_group_id='$this->id' \n"; 
    498                 $sql_base .= $sql_time_restrictions; 
    499                 $sql = $sql_base; 
    500  
    501497                /*'YES' => "Content can be shown more than once", 'NO' => "Content can only be shown once", 'ONCE_PER_NODE' => "Content can be shown more than once, but not at the same node"*/ 
    502498                $allow_repeat = $this->getAllowRepeat(); 
    503499                if ($allow_repeat == 'NO') { 
    504                     $sql_repeat = "AND content_group_element_id NOT IN (SELECT content_id FROM content_display_log WHERE user_id = '$user_id') \n"; 
     500                     $sql_repeat_join = " LEFT JOIN content_display_log ON (content_group_element_id = content_display_log.content_id AND content_display_log.user_id = '$user_id') \n"; 
     501                    $sql_repeat = " AND content_display_log.content_id  IS NULL \n"; 
    505502                } 
    506503                elseif ($allow_repeat == 'ONCE_PER_NODE') { 
    507                     $sql_repeat = "AND content_group_element_id NOT IN (SELECT content_id FROM content_display_log WHERE user_id = '$user_id' AND  node_id = '$node_id') \n"; 
     504                     $sql_repeat_join = " LEFT JOIN content_display_log ON (content_group_element_id = content_display_log.content_id AND content_display_log.user_id = '$user_id' AND content_display_log.node_id = '$node_id') \n"; 
     505                    $sql_repeat = " AND content_display_log.content_id  IS NULL \n"; 
    508506                } else { 
     507                    $sql_repeat_join = null; 
    509508                    $sql_repeat = null; 
    510509                } 
     510                $sql = "SELECT content_group_element_id FROM content_group_element $sql_repeat_join WHERE content_group_id='$this->id' \n"; 
     511                $sql .= $sql_time_restrictions; 
    511512                $sql .= $sql_repeat; 
    512513                if ($sql_redisplay) { 
     
    541542                if ($content_ordering_mode == 'PSEUDO_RANDOM') { 
    542543                    //Special case, first get only the rows that haven't been displayed before' 
    543                     $sql_no_repeat = " AND content_group_element_id NOT IN (SELECT content_id FROM content_display_log WHERE user_id = '$user_id') \n"; 
    544                     $db->execSql($sql_base . $sql_no_repeat, $element_rows, false); 
     544                    $sql_no_repeat_join = " LEFT JOIN content_display_log ON (content_group_element_id = content_display_log.content_id AND content_display_log.user_id = '$user_id') \n"; 
     545                    $sql_no_repeat_and = " AND content_display_log.content_id  IS NULL \n"; 
     546                    $sql_no_repeat = "SELECT content_group_element_id FROM content_group_element $sql_no_repeat_join WHERE content_group_id='$this->id' $sql_no_repeat_and \n"; 
     547                     
     548                    $db->execSql($sql_no_repeat, $element_rows, false); 
    545549                } 
    546550                //Normal case, or there wasn't any undisplayed content in PSEUDO_RANDOM 
  • trunk/wifidog-auth/wifidog/include/schema_validate.php

    r1316 r1334  
    4848 * Define current database schema version 
    4949 */ 
    50 define('REQUIRED_SCHEMA_VERSION', 58); 
     50define('REQUIRED_SCHEMA_VERSION', 59); 
    5151/** Used to test a new shecma version before modyfying the database */ 
    5252define('SCHEMA_UPDATE_TEST_MODE', false); 
     
    13131313    } 
    13141314 
     1315    $new_schema_version = 59; 
     1316    if ($schema_version < $new_schema_version && $new_schema_version <= $targetSchema) { 
     1317        printUpdateVersion($new_schema_version); 
     1318        $sql .= "\n\nUPDATE schema_info SET value='$new_schema_version' WHERE tag='schema_version';\n"; 
     1319        $sql .= "CREATE INDEX idx_content_display_log ON content_display_log (last_display_timestamp);\n"; 
     1320    } 
     1321     
    13151322    /* 
    13161323     $new_schema_version = ;