Skip to content

Commit 8659c78

Browse files
committed
disabled by default counting total records for pagination as it slows down (especially on large datasets)
1 parent c2f95c9 commit 8659c78

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

phpminiadmin.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@
2121
'port'=>"",#optional
2222
'chset'=>"utf8",#optional, default charset
2323
);
24+
$IS_COUNT=false; #set to true if you want to see Total records when pagination occurs (SLOWS down all select queries!)
2425
file_exists($f=dirname(__FILE__) . '/phpminiconfig.php')&&require($f); // Read from config (easier to update)
2526
if (function_exists('date_default_timezone_set')) date_default_timezone_set('UTC');#required by PHP 5.1+
2627

2728
//constants
28-
$VERSION='1.9.160630';
29+
$VERSION='1.9.160705';
2930
$MAX_ROWS_PER_PAGE=50; #max number of rows in select per one page
3031
$D="\r\n"; #default delimiter for export
3132
$BOM=chr(239).chr(187).chr(191);
@@ -1106,17 +1107,18 @@ function get_close_char($str, $pos, $ochar){
11061107
}
11071108

11081109
function do_one_sql($sql){
1109-
global $last_sth,$last_sql,$MAX_ROWS_PER_PAGE,$page,$is_limited_sql, $last_count;
1110+
global $last_sth,$last_sql,$MAX_ROWS_PER_PAGE,$page,$is_limited_sql,$last_count,$IS_COUNT;
11101111
$sql=trim($sql);
11111112
$sql=preg_replace("/;$/","",$sql);
11121113
if ($sql){
11131114
$last_sql=$sql;$is_limited_sql=0;
11141115
$last_count=NULL;
11151116
if (preg_match("/^select/i",$sql) && !preg_match("/limit +\d+/i", $sql)){
1116-
#get total count
1117-
$sql1='select count(*) from ('.$sql.') ___count_table';
1118-
$last_count=db_value($sql1,NULL,'noerr');
1119-
1117+
if ($IS_COUNT){
1118+
#get total count
1119+
$sql1='select count(*) from ('.$sql.') ___count_table';
1120+
$last_count=db_value($sql1,NULL,'noerr');
1121+
}
11201122
$offset=$page*$MAX_ROWS_PER_PAGE;
11211123
$sql.=" LIMIT $offset,$MAX_ROWS_PER_PAGE";
11221124
$is_limited_sql=1;

0 commit comments

Comments
 (0)