Sum Sybase Logical IO

From EggeWiki

In performance tuning complex Sybase queries, I usually keep an eye on the total logical IO. I've created the following one-liner to be used from within sqsh to sum up the logical IO.

<geshi lang="ruby"> | ruby -pe 'BEGIN{@sum=0}; if $_ =~ /logical reads: \(regular=\d+ apf=\d+ total=(\d+)\)/ then @sum += $1.to_i; end; END{puts "TOTAL = #{@sum}" }' </geshi>

This requires set statistics io on; and optionally set showplan on;