Skip to content

Commit

Permalink
Updates Issue#1
Browse files Browse the repository at this point in the history
Rather than adding first/last tables to calculate the time
elapsed for loading, we use the creation time of the first table (employees)
and the update time of the last table (salaries) to calculate the time.

A similar operation was added to the test_* files, so that they can
show how long the checksum operation takes.
  • Loading branch information
datacharmer committed Sep 19, 2015
1 parent 99441fd commit d59a1ec
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 2 deletions.
1 change: 1 addition & 0 deletions employees.sql
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,4 @@ source load_salaries1.dump ;
source load_salaries2.dump ;
source load_salaries3.dump ;

source show_elapsed.sql ;
1 change: 1 addition & 0 deletions employees_partitioned.sql
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,4 @@ source load_salaries1.dump ;
source load_salaries2.dump ;
source load_salaries3.dump ;

source show_elapsed.sql ;
1 change: 1 addition & 0 deletions employees_partitioned_5.1.sql
Original file line number Diff line number Diff line change
Expand Up @@ -184,3 +184,4 @@ source load_salaries1.dump ;
source load_salaries2.dump ;
source load_salaries3.dump ;

source show_elapsed.sql ;
5 changes: 5 additions & 0 deletions show_elapsed.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
select timediff(
(select update_time from information_schema.tables where table_schema='employees' and table_name='salaries'),
(select create_time from information_schema.tables where table_schema='employees' and table_name='employees')
) as data_load_time_diff;

19 changes: 18 additions & 1 deletion test_employees_md5.sql
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ CREATE TABLE expected_values (
recs int not null,
crc_sha varchar(100) not null,
crc_md5 varchar(100) not null
) ENGINE=memory;
) ENGINE=MyISAM;

-- In MySQL 5.0, the creation and update time for memory tables is not recorded
/*!50130 ALTER TABLE expected_values engine=memory */;

CREATE TABLE found_values LIKE expected_values;

INSERT INTO `expected_values` VALUES
Expand Down Expand Up @@ -102,6 +106,19 @@ SELECT
from
expected_values e INNER JOIN found_values f USING (table_name);


set @crc_fail=(select count(*) from expected_values e inner join found_values f on (e.table_name=f.table_name) where f.crc_md5 != e.crc_md5);
set @count_fail=(select count(*) from expected_values e inner join found_values f on (e.table_name=f.table_name) where f.recs != e.recs);

select timediff(
now(),
(select create_time from information_schema.tables where table_schema='employees' and table_name='expected_values')
) as computation_time;

DROP TABLE expected_values,found_values;

select 'CRC' as summary, if(@crc_fail = 0, "OK", "FAIL" ) as 'result'
union all
select 'count', if(@count_fail = 0, "OK", "FAIL" );


17 changes: 16 additions & 1 deletion test_employees_sha.sql
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ CREATE TABLE expected_values (
recs int not null,
crc_sha varchar(100) not null,
crc_md5 varchar(100) not null
) ENGINE=memory;
) ENGINE=MyISAM;

-- In MySQL 5.0, the creation and update time for memory tables is not recorded
/*!50130 ALTER TABLE expected_values engine=memory */;

CREATE TABLE found_values LIKE expected_values;

INSERT INTO `expected_values` VALUES
Expand Down Expand Up @@ -102,6 +106,17 @@ SELECT
from
expected_values e INNER JOIN found_values f USING (table_name);

set @crc_fail=(select count(*) from expected_values e inner join found_values f on (e.table_name=f.table_name) where f.crc_sha != e.crc_sha);
set @count_fail=(select count(*) from expected_values e inner join found_values f on (e.table_name=f.table_name) where f.recs != e.recs);

select timediff(
now(),
(select create_time from information_schema.tables where table_schema='employees' and table_name='expected_values')
) as computation_time;
DROP TABLE expected_values,found_values;

select 'CRC' as summary, if(@crc_fail = 0, "OK", "FAIL" ) as 'result'
union all
select 'count', if(@count_fail = 0, "OK", "FAIL" ) as 'count';


0 comments on commit d59a1ec

Please sign in to comment.