How to record the execution time of running sql statements that are stored in files?

I am doing something related to TPC-H.

I have sql statements in multiple files. I need to execute them and write the runtime as follows:

13 rows in set (0.00 sec)

I also need result sets to see if I got the correct result.
My platform is linux (centOS).

If I do this manually, I will enter such instructions in mysql:

  shell> mysql -u tpch -p
  mysql> use tpch;
  mysql> source /home/liova/download/tpch/queries/Q1.sql;
  mysql> source /home/liova/download/tpch/queries/Q2.sql;
+3
source share
2 answers

, , . , . int , (, , ..)

Date startDate = new Date();
//Run the rest of the program
Date endDate = new Date();
int msElapsedTime = startDate.getTime() - endDate.getTime();

- Java, , , runtime.exec(), mysql . , :

Date startDate = new Date();
runtime.exec("mysql db_name < /home/liova/download/tpch/queries/Q1.sql");
Date endDate = new Date();
int msElapsedTime = startDate.getTime() - endDate.getTime();

- , runtime.exec() . ...

SQL, . , SQL SQL-, . .

SQL, JDBC. tutorial. 1 5 , sql ( SQL- resultSet). - , , , .

+3

, .

1 . - , , Fred Bloggs.

2 , . , , .

3, . , (csv, xml?), .

, Test1 SQLTest1.sql SQLTest1.Actual, SQLTest1.Expected.

, , .

0

All Articles