> In SQL Statement Statistics, I do not understand if the Time column is
> for the total Count column, or for each execution. I mean if it is
> like TimeTotal(new column) = Time * Count. Or for example:
>
> -- self accu time count result sql
> -- 32% 32% 266 2 556 select
>
> if 2 executions took 266 millisencods.
Is is the accumulated time, that means it took 133 ms on average. I
will change the output from
-----------------------------------------
-- SQL Statement Statistics
-- time: total time in milliseconds
..
to
-- time: total time in milliseconds (accumulated)
> Another thing, what is the impact of the command: CALL AUTOCOMMIT()?,
> because is executed so many times.
The impact shouldn't be that big. It is called when calling
Connection.getAutoCommit(). I know Hibernate calls this method a lot.
If it is a problem I will try to optimize the method. How much time
(percentage and total milliseconds) did it take in your case?
> Also in my trace files i found this
> query: SELECT VALUE FROM INFORMATION_SCHEMA.SETTINGS WHERE NAME=?,
> like more than 900 times. This sql command it is not generated by the
> application.
This is probably also a Connection call, maybe
Connection.getQueryTimeout. How much did it take for you?
> result = 1112, count = 1; time = 0.
> I trust this is correct, because is H2, isn't?
Sure! :-)
> My point here is that Result column is greater than a 1000
> and takes 0 Time.
The statement was called once, it was very fast (0 milliseconds), and
produced an update count or rowcount of 1112 rows. That is possible.
Windows has a time resolution of about 10 milliseconds, so the query
probably took a few milliseconds. But the resolution is not a problem
if a query is executed many times (statistically the error disappears
the more often the query is executed).
I will expand the "Performance" section in the docs in the next
release as follows:
Database Profiling
The ConvertTraceFile tool generates SQL statement statistics at the
end of the SQL script file. The format used is similar to the
profiling data generated when using java -Xrunhprof. As an example,
execute the the following script using the H2 Console:
SET TRACE_LEVEL_FILE 3;
DROP TABLE IF EXISTS TEST;
CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR(255));
@LOOP 1000 INSERT INTO TEST VALUES(?, ?);
SET TRACE_LEVEL_FILE 0;
Now convert the .trace.db file using the ConvertTraceFile tool:
java -cp h2.jar org.h2.tools.ConvertTraceFile
-traceFile "~/test.trace.db" -script "~/test.sql"
The generated file test.sql will contain the SQL statements as well as
the following profiling data (results vary):
-----------------------------------------
-- SQL Statement Statistics
-- time: total time in milliseconds (accumulated)
-- count: how many times the statement ran
-- result: total update count or row count
-----------------------------------------
-- self accu time count result sql
-- 62% 62% 158 1000 1000 INSERT INTO TEST VALUES(?, ?);
-- 37% 100% 93 1 0 CREATE TABLE TEST(ID INT PRIMARY
KEY, NAME VARCHAR(255));
-- 0% 100% 0 1 0 DROP TABLE IF EXISTS TEST;
-- 0% 100% 0 1 0 SET TRACE_LEVEL_FILE 3;
Regards,
Thomas