Ignore:
Timestamp:
09/26/13 15:41:49 (11 years ago)
Author:
angelo
Message:

Ticket #3491 - Compatibilizar Expresso com novas versoes do PHP

Location:
sandbox/2.5.1-evolucao/phpgwapi/inc/adodb/perf
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • sandbox/2.5.1-evolucao/phpgwapi/inc/adodb/perf/perf-db2.inc.php

    r34 r8222  
    11<?php 
    22/*  
    3 V4.94 23 Jan 2007  (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved. 
     3V5.18 3 Sep 2012  (c) 2000-2012 John Lim (jlim#natsoft.com). All rights reserved. 
    44  Released under both BSD license and Lesser GPL library license.  
    55  Whenever there is any discrepancy between the two licenses,  
     
    5959        function perf_db2(&$conn) 
    6060        { 
    61                 $this->conn =& $conn; 
     61                $this->conn = $conn; 
    6262        } 
    6363         
  • sandbox/2.5.1-evolucao/phpgwapi/inc/adodb/perf/perf-informix.inc.php

    r34 r8222  
    11<?php 
    22/*  
    3 V4.94 23 Jan 2007  (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved. 
     3V5.18 3 Sep 2012  (c) 2000-2012 John Lim (jlim#natsoft.com). All rights reserved. 
    44  Released under both BSD license and Lesser GPL library license.  
    55  Whenever there is any discrepancy between the two licenses,  
     
    6464        function perf_informix(&$conn) 
    6565        { 
    66                 $this->conn =& $conn; 
     66                $this->conn = $conn; 
    6767        } 
    6868 
  • sandbox/2.5.1-evolucao/phpgwapi/inc/adodb/perf/perf-mssql.inc.php

    r34 r8222  
    22 
    33/*  
    4 V4.94 23 Jan 2007  (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved. 
     4V5.18 3 Sep 2012  (c) 2000-2012 John Lim (jlim#natsoft.com). All rights reserved. 
    55  Released under both BSD license and Lesser GPL library license.  
    66  Whenever there is any discrepancy between the two licenses,  
     
    7272                        //$this->explain = false; 
    7373                } 
    74                 $this->conn =& $conn; 
     74                $this->conn = $conn; 
    7575        } 
    7676         
     
    9797                $save = $ADODB_FETCH_MODE; 
    9898                $ADODB_FETCH_MODE = ADODB_FETCH_NUM; 
    99                 $rs =& $this->conn->Execute($sql); 
     99                $rs = $this->conn->Execute($sql); 
    100100                //adodb_printr($rs); 
    101101                $ADODB_FETCH_MODE = $save; 
    102                 if ($rs) { 
     102                if ($rs && !$rs->EOF) { 
    103103                        $rs->MoveNext(); 
    104104                        $s .= '<table bgcolor=white border=0 cellpadding="1" callspacing=0><tr><td nowrap align=center> Rows<td nowrap align=center> IO<td nowrap align=center> CPU<td align=left> &nbsp; &nbsp; Plan</tr>'; 
  • sandbox/2.5.1-evolucao/phpgwapi/inc/adodb/perf/perf-mysql.inc.php

    r34 r8222  
    11<?php 
    22/*  
    3 V4.94 23 Jan 2007  (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved. 
     3V5.18 3 Sep 2012  (c) 2000-2012 John Lim (jlim#natsoft.com). All rights reserved. 
    44  Released under both BSD license and Lesser GPL library license.  
    55  Whenever there is any discrepancy between the two licenses,  
     
    8484        function perf_mysql(&$conn) 
    8585        { 
    86                 $this->conn =& $conn; 
     86                $this->conn = $conn; 
    8787        } 
    8888         
     
    252252                if ($this->conn->fetchMode !== false) $savem = $this->conn->SetFetchMode(false); 
    253253                 
    254                 $rs = $this->conn->Execute('show innodb status'); 
     254                $rs = $this->conn->Execute('show engine innodb status'); 
    255255                 
    256256                if (isset($savem)) $this->conn->SetFetchMode($savem); 
  • sandbox/2.5.1-evolucao/phpgwapi/inc/adodb/perf/perf-oci8.inc.php

    r34 r8222  
    11<?php 
    22/*  
    3 V4.94 23 Jan 2007  (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved. 
     3V5.18 3 Sep 2012  (c) 2000-2012 John Lim (jlim#natsoft.com). All rights reserved. 
    44  Released under both BSD license and Lesser GPL library license.  
    55  Whenever there is any discrepancy between the two licenses,  
     
    1616if (!defined('ADODB_DIR')) die(); 
    1717 
     18 
    1819class perf_oci8 extends ADODB_perf{ 
     20 
     21        var $noShowIxora = 15; // if the sql for suspicious sql is taking too long, then disable ixora 
    1922         
    2023        var $tablesSQL = "select segment_name as \"tablename\", sum(bytes)/1024 as \"size_in_k\",tablespace_name as \"tablespace\",count(*) \"extents\" from sys.user_extents  
     
    2225          
    2326        var $version; 
     27         
    2428        var $createTableSQL = "CREATE TABLE adodb_logsql ( 
    2529                  created date NOT NULL, 
     
    6973         
    7074        'Data Cache', 
     75         
    7176                'data cache buffers' => array( 'DATAC', 
    7277                "select a.value/b.value  from v\$parameter a, v\$parameter b  
     
    7681                        "select value from v\$parameter where name='db_block_size'", 
    7782                        '' ),                    
     83         
    7884        'Memory Pools', 
    79                 'data cache size' => array('DATAC', 
     85                'Mem Max Target (11g+)' => array( 'DATAC', 
     86                "select value from v\$parameter where name = 'memory_max_target'", 
     87                        'The memory_max_size is the maximum value to which memory_target can be set.' ), 
     88        'Memory target (11g+)' => array( 'DATAC', 
     89                "select value from v\$parameter where name = 'memory_target'", 
     90                        'If memory_target is defined then SGA and PGA targets are consolidated into one memory_target.' ), 
     91                'SGA Max Size' => array( 'DATAC', 
     92                "select nvl(value,0)/1024.0/1024 || 'M' from v\$parameter where name = 'sga_max_size'", 
     93                        'The sga_max_size is the maximum value to which sga_target can be set.' ), 
     94        'SGA target' => array( 'DATAC', 
     95                "select nvl(value,0)/1024.0/1024 || 'M'  from v\$parameter where name = 'sga_target'", 
     96                        'If sga_target is defined then data cache, shared, java and large pool size can be 0. This is because all these pools are consolidated into one sga_target.' ), 
     97        'PGA aggr target' => array( 'DATAC', 
     98                "select nvl(value,0)/1024.0/1024 || 'M' from v\$parameter where name = 'pga_aggregate_target'", 
     99                        'If pga_aggregate_target is defined then this is the maximum memory that can be allocated for cursor operations such as sorts, group by, joins, merges. When in doubt, set it to 20% of sga_target.' ), 
     100        'data cache size' => array('DATAC', 
    80101                        "select value from v\$parameter where name = 'db_cache_size'", 
    81102                        'db_cache_size' ), 
     
    90111                        'this pool is for large mem allocations (not because it is larger than shared pool), for MTS sessions, parallel queries, io buffers (large_pool_size) ' ), 
    91112 
    92                 'pga buffer size' => array('CACHE',                      
    93                         "select value from v\$parameter where name='pga_aggregate_target'", 
    94                         'program global area is private memory for sorting, and hash and bitmap merges - since oracle 9i (pga_aggregate_target)' ), 
    95  
     113                'dynamic memory usage' => array('CACHE', "select '-' from dual", '=DynMemoryUsage'), 
    96114                 
    97115                'Connections', 
     
    110128                'Percentage of data cache actually in use - should be over 85%'), 
    111129                 
    112                                 'shared pool utilization ratio' => array('RATIOU',  
     130                'shared pool utilization ratio' => array('RATIOU',  
    113131                'select round((sga.bytes/case when p.value=0 then sga.bytes else to_number(p.value) end)*100,2) 
    114132                from v$sgastat sga, v$parameter p 
     
    126144                        'max in-mem sort_area_size (per query), uses memory in pga' ), 
    127145 
    128                 'pga usage at peak' => array('RATIOU', 
    129                 '=PGA','Mb utilization at peak transactions (requires Oracle 9i+)'), 
     146                /*'pga usage at peak' => array('RATIOU', 
     147                '=PGA','Mb utilization at peak transactions (requires Oracle 9i+)'),*/ 
    130148        'Transactions', 
    131149                'rollback segments' => array('ROLLBACK', 
     
    157175                        "select value from v\$parameter where name = 'optimizer_index_cost_adj'", 
    158176                        '=WarnPageCost'), 
    159                  
     177        'Waits', 
     178                'Recent wait events' => array('WAITS','select \'Top 5 events\' from dual','=TopRecentWaits'), 
     179//              'Historical wait SQL' => array('WAITS','select \'Last 2 days\' from dual','=TopHistoricalWaits'), -- requires AWR license 
     180        'Backup', 
     181                'Achivelog Mode' => array('BACKUP', 'select log_mode from v$database', '=LogMode'), 
     182         
     183                'DBID' => array('BACKUP','select dbid from v$database','Primary key of database, used for recovery with an RMAN Recovery Catalog'), 
     184                'Archive Log Dest' => array('BACKUP', "SELECT NVL(v1.value,v2.value)  
     185FROM v\$parameter v1, v\$parameter v2 WHERE v1.name='log_archive_dest' AND v2.name='log_archive_dest_10'", ''), 
     186         
     187                'Flashback Area' => array('BACKUP', "select nvl(value,'Flashback Area not used') from v\$parameter where name=lower('DB_RECOVERY_FILE_DEST')", 'Flashback area is a folder where all backup data and logs can be stored and managed by Oracle. If Error: message displayed, then it is not in use.'), 
     188         
     189                'Flashback Usage' => array('BACKUP', "select nvl('-','Flashback Area not used') from v\$parameter where name=lower('DB_RECOVERY_FILE_DEST')", '=FlashUsage', 'Flashback area usage.'), 
     190                 
     191                'Control File Keep Time' => array('BACKUP', "select value from v\$parameter where name='control_file_record_keep_time'",'No of days to keep RMAN info in control file.  Recommended set to x2 or x3 times the frequency of your full backup.'), 
     192                'Recent RMAN Jobs' => array('BACKUP', "select '-' from dual", "=RMAN"), 
     193                 
     194                //              'Control File Keep Time' => array('BACKUP', "select value from v\$parameter where name='control_file_record_keep_time'",'No of days to keep RMAN info in control file. I recommend it be set to x2 or x3 times the frequency of your full backup.'), 
     195      'Storage', 'Tablespaces' => array('TABLESPACE', "select '-' from dual", "=TableSpace"), 
    160196                false 
    161197                 
     
    165201        function perf_oci8(&$conn) 
    166202        { 
     203        global $gSQLBlockRows; 
     204         
     205                $gSQLBlockRows = 1000; 
    167206                $savelog = $conn->LogSQL(false);         
    168207                $this->version = $conn->ServerInfo(); 
    169208                $conn->LogSQL($savelog);         
    170                 $this->conn =& $conn; 
    171         } 
    172          
     209                $this->conn = $conn; 
     210        } 
     211         
     212        function LogMode() 
     213        { 
     214                $mode = $this->conn->GetOne("select log_mode from v\$database"); 
     215                 
     216                if ($mode == 'ARCHIVELOG') return 'To turn off archivelog:<br> 
     217        <pre><font size=-2> 
     218        SQLPLUS> connect sys as sysdba; 
     219        SQLPLUS> shutdown immediate; 
     220 
     221        SQLPLUS> startup mount exclusive; 
     222        SQLPLUS> alter database noarchivelog; 
     223        SQLPLUS> alter database open; 
     224</font></pre>'; 
     225                 
     226                return 'To turn on archivelog:<br> 
     227        <pre><font size=-2> 
     228        SQLPLUS> connect sys as sysdba; 
     229        SQLPLUS> shutdown immediate; 
     230 
     231        SQLPLUS> startup mount exclusive; 
     232        SQLPLUS> alter database archivelog; 
     233        SQLPLUS> archive log start; 
     234        SQLPLUS> alter database open; 
     235</font></pre>'; 
     236        } 
     237         
     238        function TopRecentWaits() 
     239        { 
     240                 
     241                $rs = $this->conn->Execute("select * from (    
     242                select event, round(100*time_waited/(select sum(time_waited) from v\$system_event where wait_class <> 'Idle'),1) \"% Wait\", 
     243    total_waits,time_waited, average_wait,wait_class from v\$system_event where wait_class <> 'Idle' order by 2 desc 
     244        ) where rownum <=5"); 
     245                 
     246                $ret = rs2html($rs,false,false,false,false);             
     247                return "&nbsp;<p>".$ret."&nbsp;</p>"; 
     248                 
     249        } 
     250         
     251        function TopHistoricalWaits() 
     252        { 
     253                $days = 2; 
     254                 
     255                $rs = $this->conn->Execute("select * from (   SELECT 
     256         b.wait_class,B.NAME, 
     257        round(sum(wait_time+TIME_WAITED)/1000000) waitsecs, 
     258        parsing_schema_name, 
     259        C.SQL_TEXT, a.sql_id 
     260FROM    V\$ACTIVE_SESSION_HISTORY A 
     261        join V\$EVENT_NAME B  on  A.EVENT# = B.EVENT# 
     262       join V\$SQLAREA C  on  A.SQL_ID = C.SQL_ID 
     263WHERE   A.SAMPLE_TIME BETWEEN sysdate-$days and sysdate 
     264       and parsing_schema_name not in ('SYS','SYSMAN','DBSNMP','SYSTEM') 
     265GROUP BY b.wait_class,parsing_schema_name,C.SQL_TEXT, B.NAME,A.sql_id 
     266order by 3 desc) where rownum <=10"); 
     267                 
     268                $ret = rs2html($rs,false,false,false,false);             
     269                return "&nbsp;<p>".$ret."&nbsp;</p>"; 
     270                 
     271        } 
     272         
     273        function TableSpace() 
     274        { 
     275 
     276                $rs = $this->conn->Execute( 
     277        "select tablespace_name,round(sum(bytes)/1024/1024) as Used_MB,round(sum(maxbytes)/1024/1024) as Max_MB, round(sum(bytes)/sum(maxbytes),4) * 100 as PCT  
     278        from dba_data_files 
     279   group by tablespace_name order by 2 desc"); 
     280                 
     281                $ret = "<p><b>Tablespace</b>".rs2html($rs,false,false,false,false); 
     282 
     283                $rs = $this->conn->Execute("select * from dba_data_files order by tablespace_name, 1"); 
     284                $ret .= "<p><b>Datafile</b>".rs2html($rs,false,false,false,false); 
     285                 
     286                return "&nbsp;<p>".$ret."&nbsp;</p>"; 
     287        } 
     288         
     289        function RMAN() 
     290        { 
     291                $rs = $this->conn->Execute("select * from (select start_time, end_time, operation, status, mbytes_processed, output_device_type   
     292                        from V\$RMAN_STATUS order by start_time desc) where rownum <=10"); 
     293                 
     294                $ret = rs2html($rs,false,false,false,false);             
     295                return "&nbsp;<p>".$ret."&nbsp;</p>"; 
     296                 
     297        } 
     298 
     299        function DynMemoryUsage() 
     300        { 
     301                if (@$this->version['version'] >= 11) { 
     302                        $rs = $this->conn->Execute("select component, current_size/1024./1024 as \"CurrSize (M)\" from  V\$MEMORY_DYNAMIC_COMPONENTS"); 
     303 
     304                } else 
     305                        $rs = $this->conn->Execute("select name, round(bytes/1024./1024,2) as \"CurrSize (M)\" from  V\$sgainfo"); 
     306 
     307                         
     308                $ret = rs2html($rs,false,false,false,false);             
     309                return "&nbsp;<p>".$ret."&nbsp;</p>"; 
     310        } 
     311 
     312        function FlashUsage() 
     313        { 
     314        $rs = $this->conn->Execute("select * from  V\$FLASH_RECOVERY_AREA_USAGE"); 
     315                $ret = rs2html($rs,false,false,false,false);             
     316                return "&nbsp;<p>".$ret."&nbsp;</p>"; 
     317        } 
     318 
    173319        function WarnPageCost($val) 
    174320        { 
    175                 if ($val == 100) $s = '<font color=red><b>Too High</b>. </font>'; 
     321                if ($val == 100 && $this->version['version'] < 10) $s = '<font color=red><b>Too High</b>. </font>'; 
    176322                else $s = ''; 
    177323                 
    178324                return $s.'Recommended is 20-50 for TP, and 50 for data warehouses. Default is 100. See <a href=http://www.dba-oracle.com/oracle_tips_cost_adj.htm>optimizer_index_cost_adj</a>. '; 
    179325        } 
    180          
     326 
    181327        function WarnIndexCost($val) 
    182328        { 
    183                 if ($val == 0) $s = '<font color=red><b>Too Low</b>. </font>'; 
     329                if ($val == 0 && $this->version['version'] < 10) $s = '<font color=red><b>Too Low</b>. </font>'; 
    184330                else $s = ''; 
    185331                 
    186332                return $s.'Percentage of indexed data blocks expected in the cache. 
    187                         Recommended is 20 (fast disk array) to 50 (slower hard disks). Default is 0. 
     333                        Recommended is 20 (fast disk array) to 30 (slower hard disks). Default is 0. 
    188334                         See <a href=http://www.dba-oracle.com/oracle_tips_cbo_part1.htm>optimizer_index_caching</a>.'; 
    189335                } 
    190336         
    191337        function PGA() 
    192         { 
    193                 if ($this->version['version'] < 9) return 'Oracle 9i or later required'; 
    194                  
    195                 $rs = $this->conn->Execute("select a.mb,a.targ as pga_size_pct,a.pct from  
    196            (select round(pga_target_for_estimate/1024.0/1024.0,0) Mb, 
    197                    pga_target_factor targ,estd_pga_cache_hit_percentage pct,rownum as r  
    198                    from v\$pga_target_advice) a left join 
    199            (select round(pga_target_for_estimate/1024.0/1024.0,0) Mb, 
    200                    pga_target_factor targ,estd_pga_cache_hit_percentage pct,rownum as r  
    201                    from v\$pga_target_advice) b on  
    202           a.r = b.r+1 where  
    203                 b.pct < 100"); 
    204                 if (!$rs) return "Only in 9i or later"; 
    205                 $rs->Close(); 
    206                 if ($rs->EOF) return "PGA could be too big"; 
    207                  
    208                 return reset($rs->fields); 
    209         } 
    210          
     338        {        
     339                 
     340                //if ($this->version['version'] < 9) return 'Oracle 9i or later required'; 
     341        } 
     342 
     343        function PGA_Advice() 
     344        { 
     345                $t = "<h3>PGA Advice Estimate</h3>"; 
     346                if ($this->version['version'] < 9) return $t.'Oracle 9i or later required'; 
     347                 
     348                $rs = $this->conn->Execute('select a.MB, 
     349                        case when a.targ = 1 then \'<<= Current \'  
     350                        when a.targ < 1  or a.pct <= b.pct then null  
     351                        else  
     352                        \'- BETTER than Current by \'||round(a.pct/b.pct*100-100,2)||\'%\' end as "Percent Improved", 
     353        a.targ as  "PGA Size Factor",a.pct "% Perf" 
     354        from  
     355       (select round(pga_target_for_estimate/1024.0/1024.0,0) MB, 
     356              pga_target_factor targ,estd_pga_cache_hit_percentage pct,rownum as r  
     357              from v$pga_target_advice) a left join 
     358       (select round(pga_target_for_estimate/1024.0/1024.0,0) MB, 
     359              pga_target_factor targ,estd_pga_cache_hit_percentage pct,rownum as r  
     360              from v$pga_target_advice) b on  
     361      a.r = b.r+1 where  
     362          b.pct < 100'); 
     363                if (!$rs) return $t."Only in 9i or later"; 
     364        //      $rs->Close(); 
     365                if ($rs->EOF) return $t."PGA could be too big"; 
     366                 
     367                return $t.rs2html($rs,false,false,true,false); 
     368        } 
     369 
    211370        function Explain($sql,$partial=false)  
    212371        { 
    213372                $savelog = $this->conn->LogSQL(false); 
    214                 $rs =& $this->conn->SelectLimit("select ID FROM PLAN_TABLE"); 
     373                $rs = $this->conn->SelectLimit("select ID FROM PLAN_TABLE"); 
    215374                if (!$rs) { 
    216375                        echo "<p><b>Missing PLAN_TABLE</b></p> 
     
    251410                if ($partial) { 
    252411                        $sqlq = $this->conn->qstr($sql.'%'); 
    253                         $arr = $this->conn->GetArray("select distinct distinct sql1 from adodb_logsql where sql1 like $sqlq"); 
     412                        $arr = $this->conn->GetArray("select distinct sql1 from adodb_logsql where sql1 like $sqlq"); 
    254413                        if ($arr) { 
    255414                                foreach($arr as $row) { 
     
    265424                $id = "ADODB ".microtime(); 
    266425 
    267                 $rs =& $this->conn->Execute("EXPLAIN PLAN SET STATEMENT_ID='$id' FOR $sql"); 
     426                $rs = $this->conn->Execute("EXPLAIN PLAN SET STATEMENT_ID='$id' FOR $sql"); 
    268427                $m = $this->conn->ErrorMsg(); 
    269428                if ($m) { 
     
    273432                        return $s; 
    274433                } 
    275                 $rs =& $this->conn->Execute(" 
     434                $rs = $this->conn->Execute(" 
    276435                select  
    277436  '<pre>'||lpad('--', (level-1)*2,'-') || trim(operation) || ' ' || trim(options)||'</pre>'  as Operation,  
     
    287446                return $s; 
    288447        } 
    289          
    290          
     448 
    291449        function CheckMemory() 
    292450        { 
    293451                if ($this->version['version'] < 9) return 'Oracle 9i or later required'; 
    294452                 
    295                  $rs =& $this->conn->Execute(" 
    296 select  a.size_for_estimate as cache_mb_estimate, 
    297         case when a.size_factor=1 then  
    298                 '&lt;&lt;= current' 
    299          when a.estd_physical_read_factor-b.estd_physical_read_factor > 0 and a.estd_physical_read_factor<1 then 
    300                 '- BETTER - ' 
    301         else ' ' end as currsize,  
    302    a.estd_physical_read_factor-b.estd_physical_read_factor as best_when_0 
    303    from (select size_for_estimate,size_factor,estd_physical_read_factor,rownum  r from v\$db_cache_advice) a ,  
    304    (select size_for_estimate,size_factor,estd_physical_read_factor,rownum r from v\$db_cache_advice) b where a.r = b.r-1"); 
     453                 $rs = $this->conn->Execute(" 
     454select  a.name Buffer_Pool, b.size_for_estimate as cache_mb_estimate,  
     455        case when b.size_factor=1 then  
     456                '&lt;&lt;= Current' 
     457         when a.estd_physical_read_factor-b.estd_physical_read_factor > 0.001 and b.estd_physical_read_factor<1 then 
     458                '- BETTER than current by ' || round((1-b.estd_physical_read_factor)/b.estd_physical_read_factor*100,2) || '%' 
     459        else ' ' end as RATING,  
     460   b.estd_physical_read_factor \"Phys. Reads Factor\", 
     461   round((a.estd_physical_read_factor-b.estd_physical_read_factor)/b.estd_physical_read_factor*100,2) as \"% Improve\" 
     462   from (select size_for_estimate,size_factor,estd_physical_read_factor,rownum  r,name from v\$db_cache_advice order by name,1) a ,  
     463   (select size_for_estimate,size_factor,estd_physical_read_factor,rownum r,name from v\$db_cache_advice order by name,1) b  
     464   where a.r = b.r-1 and a.name = b.name 
     465  "); 
    305466                if (!$rs) return false; 
    306467                 
     
    308469                The v$db_cache_advice utility show the marginal changes in physical data block reads for different sizes of db_cache_size 
    309470                */ 
    310                 $s = "<h3>Data Cache Estimate</h3>"; 
     471                $s = "<h3>Data Cache Advice Estimate</h3>"; 
    311472                if ($rs->EOF) { 
    312473                        $s .= "<p>Cache that is 50% of current size is still too big</p>"; 
    313474                } else { 
    314                         $s .= "Ideal size of Data Cache is when \"best_when_0\" changes from a positive number and becomes zero."; 
     475                        $s .= "Ideal size of Data Cache is when %BETTER gets close to zero."; 
    315476                        $s .= rs2html($rs,false,false,false,false); 
    316477                } 
    317                 return $s; 
    318         } 
    319          
     478                return $s.$this->PGA_Advice(); 
     479        } 
     480 
    320481        /* 
    321482                Generate html for suspicious/expensive sql 
     
    413574                 
    414575                $s = ''; 
     576                $timer = time(); 
    415577                $s .= $this->_SuspiciousSQL($numsql); 
     578                $timer = time() - $timer; 
     579                 
     580                if ($timer > $this->noShowIxora) return $s; 
    416581                $s .= '<p>'; 
    417582                 
     
    421586                 
    422587                $savelog = $this->conn->LogSQL(false); 
    423                 $rs =& $this->conn->SelectLimit($sql); 
     588                $rs = $this->conn->SelectLimit($sql); 
    424589                $this->conn->LogSQL($savelog); 
    425590                 
     
    485650                 
    486651                $s = '';                 
     652                $timer = time(); 
    487653                $s .= $this->_ExpensiveSQL($numsql); 
     654                $timer = time() - $timer; 
     655                if ($timer > $this->noShowIxora) return $s; 
     656                 
    488657                $s .= '<p>'; 
    489658                $save = $ADODB_CACHE_MODE; 
     
    492661                 
    493662                $savelog = $this->conn->LogSQL(false); 
    494                 $rs =& $this->conn->Execute($sql); 
     663                $rs = $this->conn->Execute($sql); 
    495664                $this->conn->LogSQL($savelog); 
    496665                 
     
    506675        } 
    507676         
     677        function clearsql()  
     678        { 
     679                $perf_table = adodb_perf::table(); 
     680        // using the naive "delete from $perf_table where created<".$this->conn->sysTimeStamp will cause the table to lock, possibly 
     681        // for a long time 
     682                $sql =  
     683"DECLARE cnt pls_integer; 
     684BEGIN 
     685        cnt := 0; 
     686        FOR rec IN (SELECT ROWID AS rr FROM $perf_table WHERE created<SYSDATE)  
     687        LOOP 
     688          cnt := cnt + 1; 
     689          DELETE FROM $perf_table WHERE ROWID=rec.rr; 
     690          IF cnt = 1000 THEN 
     691                COMMIT; 
     692                cnt := 0; 
     693          END IF; 
     694        END LOOP; 
     695        commit; 
     696END;"; 
     697 
     698                $ok = $this->conn->Execute($sql); 
     699        } 
     700         
    508701} 
    509702?> 
  • sandbox/2.5.1-evolucao/phpgwapi/inc/adodb/perf/perf-postgres.inc.php

    r34 r8222  
    22 
    33/*  
    4 V4.94 23 Jan 2007  (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved. 
     4V5.18 3 Sep 2012  (c) 2000-2012 John Lim (jlim#natsoft.com). All rights reserved. 
    55  Released under both BSD license and Lesser GPL library license.  
    66  Whenever there is any discrepancy between the two licenses,  
     
    9090        function perf_postgres(&$conn) 
    9191        { 
    92                 $this->conn =& $conn; 
     92                $this->conn = $conn; 
     93        } 
     94         
     95        var $optimizeTableLow  = 'VACUUM %s';  
     96        var $optimizeTableHigh = 'VACUUM ANALYZE %s'; 
     97 
     98/** 
     99 * @see adodb_perf#optimizeTable 
     100 */ 
     101 
     102        function optimizeTable($table, $mode = ADODB_OPT_LOW)  
     103        { 
     104            if(! is_string($table)) return false; 
     105             
     106            $conn = $this->conn; 
     107            if (! $conn) return false; 
     108             
     109            $sql = ''; 
     110            switch($mode) { 
     111                case ADODB_OPT_LOW : $sql = $this->optimizeTableLow;  break; 
     112                case ADODB_OPT_HIGH: $sql = $this->optimizeTableHigh; break; 
     113                default            :  
     114                { 
     115                    ADOConnection::outp(sprintf("<p>%s: '%s' using of undefined mode '%s'</p>", __CLASS__, 'optimizeTable', $mode)); 
     116                    return false; 
     117                } 
     118            } 
     119            $sql = sprintf($sql, $table); 
     120             
     121            return $conn->Execute($sql) !== false;   
    93122        } 
    94123         
Note: See TracChangeset for help on using the changeset viewer.