If anyone is familiar with Oracle, there is a way to trace a file. Then there is is a script called tkprof that will generate a report that includes a rollup of some values. The problem with this script is that it only does the rollup properly if the query is finished. So I need something quick and dirty that I can run while the query is running so I can get an idea of what part of the query is taking the longest.
There are ways to do this in the DB, but I want to try this.
The following is my take on it, using only shell builtins. I had to trim the first few digits of "tim" to use integer arithmetics (otherwise there would be overruns), you might want to find a more "long-term solution" for this. After all, the script is still a quick hack.
After the sorting and parsing it comes down to a simple group change with "$obj" as the group identifier.
Code:
#!/bin/ksh
print_summary ()
{
typeset obj="$1"
typeset -i elasum="$2"
typeset -i timsum="$3"
print - "Summary Object: $obj"
print - " - Sum ela: $elasum"
print - " - Sum tim: $timsum"
return 0
}
# main ()
typeset obj=""
typeset ela=0
typeset time=0
typeset lastobj=""
typeset -i elasum=0
typeset -i timsum=0
typeset infile="/home/bakunin/tmp/oralog/input"
IFS=' '
grep '^WAIT' $infile |\
sort -k 12.6 |\
while read x x x x x x x ela x x x obj time x ; do
obj="${obj#obj#=}" # "cook" the input
time="${time#tim=5692604}"
# print obj=$obj ela=$ela tim=$tim # just for testing
# simple group change
if [ "$obj" != "$lastobj" ] ; then
if [ -n "$lastobj" ] ; then
print_summary "$obj" $elasum $timsum
elasum=0
timsum=0
fi
lastobj="$obj"
fi
(( elasum += ela ))
(( timsum += time ))
done
print_summary "$obj" $elasum $timsum # print last group
exit 0
Hello,
I have a file with two fields in the following format..
NewYork|Rob
Boston|Mellisa
NewYork|Kevin
Boston|John
Chicago|Mike
Boston|Tom
My output should be:
NewYork|Rob,Kevin
Boston|Mellisa,John,Tom
Chicago|Mike
Basically I need to rollup on column A and stringconcat column... (5 Replies)
Hi ,
I used the below script to get the sql data into csv file using unix scripting.
I m getting the output into an output file but the output file is not displayed in a separe columns .
#!/bin/ksh
export FILE_PATH=/maav/home/xyz/abc/
rm $FILE_PATH/sample.csv
sqlplus -s... (2 Replies)
Hi guys,
I am new on here, I have a function in oracle that returns a specific value:
create or replace
PACKAGE BODY "CTC_ASDGET_SCHED" AS
FUNCTION FN_ASDSCHEDULE_GET
RETURN VARCHAR2
AS
BEGIN
DECLARE
ASDSchedule varchar2(6);
ASDComplete... (1 Reply)
How do I dynamically assign the below output to unix shell variables
so I can build a menu in a shell script?
Example:
var1 = 1 var2= SYSTEM
var3 = 2 var4= UNDOTBS1
and so on, then in the shell script I can use the variables to build a menu.
set serveroutput on
declare... (2 Replies)