Changeset 164


Ignore:
Timestamp:
04/18/2006 06:10:06 AM (6 years ago)
Author:
cirrus
Message:

Optimization: Added 3 key index on the links table.
Optimization: Changed the db_data function in the table class, to avoid a duplicate query.
Thanks to Winner.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/globals/classes/table.php

    r102 r164  
    3232                global $db, $vars; 
    3333                if ($limit == '' && $limit !== FALSE) { 
    34                         $cnt = $db->cnt($select, $from, $where, $group_by); 
     34                        if ($this->info['CURRENT_PAGE'] == '' && $_SERVER['REQUEST_METHOD'] == 'GET') $this->info['CURRENT_PAGE'] = get($this->info['TABLE_NAME']."_showpage"); 
     35                        if ($this->info['CURRENT_PAGE'] == '') $this->info['CURRENT_PAGE'] = 1; 
     36                        $page = $this->info['CURRENT_PAGE']; 
     37                        $limit = (($page-1)*$vars['constructor']['max_rows']).', '.$vars['constructor']['max_rows']; 
     38                        $want_pages = true; 
     39                        } 
     40                $data = $db->get("SQL_CALC_FOUND_ROWS ".$select, $from, $where, $group_by, $order_by, $limit); 
     41                if (isset($want_pages)) { 
     42                        $cnt = $db->query_data("SELECT FOUND_ROWS()"); 
     43                        $cnt = $cnt[0]['FOUND_ROWS()']; 
    3544                        if ($vars['constructor']['max_rows'] != '' && $cnt > $vars['constructor']['max_rows']) { 
    3645                                $this->info['TOTAL_PAGES'] = ceil($cnt / $vars['constructor']['max_rows']); 
    37                                  
    38                                 if ($this->info['CURRENT_PAGE'] == '' && $_SERVER['REQUEST_METHOD'] == 'GET') $this->info['CURRENT_PAGE'] = get($this->info['TABLE_NAME']."_showpage"); 
    39                                 if ($this->info['CURRENT_PAGE'] == '') $this->info['CURRENT_PAGE'] = 1; 
    40                                  
    41                                 $page = $this->info['CURRENT_PAGE']; 
    42                                 $limit = (($page-1)*$vars['constructor']['max_rows']).', '.$vars['constructor']['max_rows']; 
    43  
    4446                                for ($i=1;$i<=$this->info['TOTAL_PAGES'];$i++) { 
    4547                                        $this->info['PAGES'][$i] = makelink(array($this->info['TABLE_NAME']."_showpage" => $i), TRUE); 
     
    4749                        } 
    4850                } 
    49                 $data = $db->get($select, $from, $where, $group_by, $order_by, $limit); 
    5051                if (isset($data[0])) { 
    5152                        $isset = TRUE; 
  • trunk/install/schema.sql

    r156 r164  
    107107  `info` text, 
    108108  PRIMARY KEY  (`id`), 
    109   KEY `node_id` (`node_id`), 
    110   KEY `peer_node_id` (`peer_node_id`), 
     109  KEY `node_id` (`node_id`,`type`,`status`), 
     110  KEY `peer_node_id` (`peer_node_id`,`type`,`status`), 
    111111  KEY `type` (`type`), 
    112112  KEY `status` (`status`), 
    113   KEY `peer_ap_id` (`peer_ap_id`) 
     113  KEY `peer_ap_id` (`peer_ap_id`,`type`,`status`) 
    114114) ENGINE=MyISAM DEFAULT CHARSET=utf8; 
    115115 
Note: See TracChangeset for help on using the changeset viewer.