Skip to content

Commit 0732d32

Browse files
author
xaver
committed
join fix - disappered in commit + Switch traffic joins, because its faster - Tested in a productive system (MySQL 5.1) as query few tausend domains 1-3 sec for Webtraffic sort, faster SQL = faster and MySQL 5.5 is much faster with joins (standard is not sorted with slow traffic querys) -> slowest part is coping the tables into temp -> more tweeks on cache... -> faster by heavy use
1 parent 05e1f39 commit 0732d32

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

interface/lib/classes/listform_actions.inc.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -58,28 +58,28 @@ public function onLoad()
5858

5959
//* Manipulate order by for sorting / Every list has a stored value
6060
//* Against notice error
61-
if(!isset($_SESSION['search'][$app->listform->listDef["name"]]['order'])){
62-
$_SESSION['search'][$app->listform->listDef["name"]]['order'] = '';
61+
if(!isset($_SESSION['search'][$app->listform->listDef["name"].$app->listform->listDef['table']]['order'])){
62+
$_SESSION['search'][$app->listform->listDef["name"].$app->listform->listDef['table']]['order'] = '';
6363
}
6464

6565
if(!empty($_GET['orderby'])){
6666
$order = str_replace('tbl_col_','',$_GET['orderby']);
6767
//* Check the css class submited value
6868
if (preg_match("/^[a-z\_]{1,}$/",$order)) {
69-
if($_SESSION['search'][$app->listform->listDef["name"]]['order'] == $order){
70-
$_SESSION['search'][$app->listform->listDef["name"]]['order'] = $order.' DESC';
69+
if($_SESSION['search'][$app->listform->listDef["name"].$app->listform->listDef['table']]['order'] == $order){
70+
$_SESSION['search'][$app->listform->listDef["name"].$app->listform->listDef['table']]['order'] = $order.' DESC';
7171
} else {
72-
$_SESSION['search'][$app->listform->listDef["name"]]['order'] = $order;
72+
$_SESSION['search'][$app->listform->listDef["name"].$app->listform->listDef['table']]['order'] = $order;
7373
}
7474
}
7575
}
7676

7777
// If a manuel oder by like customers isset the sorting will be infront
78-
if(!empty($_SESSION['search'][$app->listform->listDef["name"]]['order'])){
78+
if(!empty($_SESSION['search'][$app->listform->listDef["name"].$app->listform->listDef['table']]['order'])){
7979
if(empty($this->SQLOrderBy)){
80-
$this->SQLOrderBy = "ORDER BY ".$_SESSION['search'][$app->listform->listDef["name"]]['order'];
80+
$this->SQLOrderBy = "ORDER BY ".$_SESSION['search'][$app->listform->listDef["name"].$app->listform->listDef['table']]['order'];
8181
} else {
82-
$this->SQLOrderBy = str_replace("ORDER BY ","ORDER BY ".$_SESSION['search'][$app->listform->listDef["name"]]['order'].', ',$this->SQLOrderBy);
82+
$this->SQLOrderBy = str_replace("ORDER BY ","ORDER BY ".$_SESSION['search'][$app->listform->listDef["name"].$app->listform->listDef['table']]['order'].', ',$this->SQLOrderBy);
8383
}
8484
}
8585

@@ -196,53 +196,53 @@ private function getQueryString() {
196196
$tmp_year = date('Y',mktime(0, 0, 0, date("m")-1, date("d"), date("Y")));
197197
$tmp_month = date('m',mktime(0, 0, 0, date("m")-1, date("d"), date("Y")));
198198
$extselect .= ', SUM(wt.traffic_bytes) as calctraffic';
199-
$join .= ' JOIN web_traffic as wt ON '.$app->listform->listDef['table'].'.domain = wt.hostname ';
199+
$join .= ' INNER JOIN web_traffic as wt ON '.$app->listform->listDef['table'].'.domain = wt.hostname ';
200200
$sql_where .= " AND YEAR(wt.traffic_date) = '$tmp_year' AND MONTH(wt.traffic_date) = '$tmp_month'";
201201
$order_by_sql = str_replace('web_traffic_last_month','calctraffic',$order_by_sql);
202202
$order_by_sql = "GROUP BY domain ".$order_by_sql;
203203
} elseif($order == 'web_traffic_this_month'){
204204
$tmp_year = date('Y');
205205
$tmp_month = date('m');
206206
$extselect .= ', SUM(wt.traffic_bytes) as calctraffic';
207-
$join .= ' JOIN web_traffic as wt ON '.$app->listform->listDef['table'].'.domain = wt.hostname ';
207+
$join .= ' INNER JOIN web_traffic as wt ON '.$app->listform->listDef['table'].'.domain = wt.hostname ';
208208
$sql_where .= " AND YEAR(wt.traffic_date) = '$tmp_year' AND MONTH(wt.traffic_date) = '$tmp_month'";
209209
$order_by_sql = str_replace('web_traffic_this_month','calctraffic',$order_by_sql);
210210
$order_by_sql = "GROUP BY domain ".$order_by_sql;
211211
} elseif($order == 'web_traffic_last_year'){
212212
$tmp_year = date('Y',mktime(0, 0, 0, date("m")-1, date("d"), date("Y")));
213213
$extselect .= ', SUM(wt.traffic_bytes) as calctraffic';
214-
$join .= ' JOIN web_traffic as wt ON '.$app->listform->listDef['table'].'.domain = wt.hostname ';
214+
$join .= ' INNER JOIN web_traffic as wt ON '.$app->listform->listDef['table'].'.domain = wt.hostname ';
215215
$sql_where .= " AND YEAR(wt.traffic_date) = '$tmp_year'";
216216
$order_by_sql = str_replace('web_traffic_last_year','calctraffic',$order_by_sql);
217217
$order_by_sql = "GROUP BY domain ".$order_by_sql;
218218
} elseif($order == 'web_traffic_this_year'){
219219
$tmp_year = date('Y');
220220
$extselect .= ', SUM(wt.traffic_bytes) as calctraffic';
221-
$join .= ' JOIN web_traffic as wt ON '.$app->listform->listDef['table'].'.domain = wt.hostname ';
221+
$join .= ' INNER JOIN web_traffic as wt ON '.$app->listform->listDef['table'].'.domain = wt.hostname ';
222222
$sql_where .= " AND YEAR(wt.traffic_date) = '$tmp_year'";
223223
$order_by_sql = str_replace('web_traffic_this_year','calctraffic',$order_by_sql);
224224
$order_by_sql = "GROUP BY domain ".$order_by_sql;
225225
} elseif($order == 'mail_traffic_last_month'){
226226
$tmp_date = date('Y-m',mktime(0, 0, 0, date("m")-1, date("d"), date("Y")));
227-
$join .= ' JOIN mail_traffic as mt ON '.$app->listform->listDef['table'].'.mailuser_id = mt.mailuser_id ';
227+
$join .= ' INNER JOIN mail_traffic as mt ON '.$app->listform->listDef['table'].'.mailuser_id = mt.mailuser_id ';
228228
$sql_where .= " AND mt.month like '$tmp_date%'";
229229
$order_by_sql = str_replace('mail_traffic_last_month','traffic',$order_by_sql);
230230
} elseif($order == 'mail_traffic_this_month'){
231231
$tmp_date = date('Y-m');
232-
$join .= ' JOIN mail_traffic as mt ON '.$app->listform->listDef['table'].'.mailuser_id = mt.mailuser_id ';
232+
$join .= ' INNER JOIN mail_traffic as mt ON '.$app->listform->listDef['table'].'.mailuser_id = mt.mailuser_id ';
233233
$sql_where .= " AND mt.month like '$tmp_date%'";
234234
$order_by_sql = str_replace('mail_traffic_this_month','traffic',$order_by_sql);
235235
} elseif($order == 'mail_traffic_last_year'){
236236
$tmp_date = date('Y',mktime(0, 0, 0, date("m")-1, date("d"), date("Y")));
237237
$extselect .= ', SUM(mt.traffic) as calctraffic';
238-
$join .= ' JOIN mail_traffic as mt ON '.$app->listform->listDef['table'].'.mailuser_id = mt.mailuser_id ';
238+
$join .= ' INNER JOIN mail_traffic as mt ON '.$app->listform->listDef['table'].'.mailuser_id = mt.mailuser_id ';
239239
$sql_where .= " AND mt.month like '$tmp_date%'";;
240240
$order_by_sql = str_replace('mail_traffic_last_year','calctraffic',$order_by_sql);
241241
$order_by_sql = "GROUP BY mailuser_id ".$order_by_sql;
242242
} elseif($order == 'mail_traffic_this_year'){
243243
$tmp_date = date('Y');
244244
$extselect .= ', SUM(mt.traffic) as calctraffic';
245-
$join .= ' JOIN mail_traffic as mt ON '.$app->listform->listDef['table'].'.mailuser_id = mt.mailuser_id ';
245+
$join .= ' INNER JOIN mail_traffic as mt ON '.$app->listform->listDef['table'].'.mailuser_id = mt.mailuser_id ';
246246
$sql_where .= " AND mt.month like '$tmp_date%'";
247247
$order_by_sql = str_replace('mail_traffic_this_year','calctraffic',$order_by_sql);
248248
$order_by_sql = "GROUP BY mailuser_id ".$order_by_sql;

0 commit comments

Comments
 (0)