Index: openacs-4/packages/acs-tcl/tcl/00-database-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/00-database-procs.tcl,v diff -u -r1.53 -r1.54 --- openacs-4/packages/acs-tcl/tcl/00-database-procs.tcl 13 Jan 2005 13:55:55 -0000 1.53 +++ openacs-4/packages/acs-tcl/tcl/00-database-procs.tcl 17 Feb 2005 15:12:35 -0000 1.54 @@ -641,14 +641,14 @@ # if a table is being created, we need to bypass things, too (OpenACS - Ben). set test_sql [db_qd_replace_sql $full_statement_name $sql] if {[regexp -nocase -- {^\s*select} $test_sql match]} { - ns_log Debug "PLPGSQL: bypassed anon function" + # ns_log Debug "PLPGSQL: bypassed anon function" set selection [db_exec 0or1row $db $full_statement_name $sql] } elseif {[regexp -nocase -- {^\s*create table} $test_sql match] || [regexp -nocase -- {^\s*drop table} $test_sql match]} { - ns_log Debug "PLPGSQL: bypassed anon function -- create/drop table" + ns_log Debug "PLPGSQL: bypassed anon function for create/drop table" set selection [db_exec dml $db $full_statement_name $sql] return "" } else { - ns_log Debug "PLPGSQL: using anonymous function" + # ns_log Debug "PLPGSQL: using anonymous function" set selection [db_exec_plpgsql $db $full_statement_name $sql \ $statement_name] } @@ -904,6 +904,7 @@ } { set start_time [clock clicks -milliseconds] + set start_time_fine [clock clicks] set driverkey [db_driverkey -handle_p 1 $db] # Note: Although marked as private, db_exec is in fact called @@ -996,6 +997,14 @@ } } error] + # JCD: we log the clicks, dbname, query time, and statement to catch long running queries. + # If we took more than 5 seconds yack about it. + if { [expr [clock clicks -milliseconds] - $start_time] > 5000} { + ns_log Warning "db_exec: longdb [expr [clock clicks] - $start_time_fine] $db $type $statement_name" + } else { + ns_log Debug "db_exec: timing [expr [clock clicks] - $start_time_fine] $db $type $statement_name" + } + ad_call_proc_if_exists ds_collect_db_call $db $type $statement_name $sql $start_time $errno $error if { $errno == 2 } { return $error