config root man

Current Path : /home/usr.opt/mysql57/mysql-test/suite/ndb/t/

FreeBSD hs32.drive.ne.jp 9.1-RELEASE FreeBSD 9.1-RELEASE #1: Wed Jan 14 12:18:08 JST 2015 root@hs32.drive.ne.jp:/sys/amd64/compile/hs32 amd64
Upload File :
Current File : //home/usr.opt/mysql57/mysql-test/suite/ndb/t/ndb_index_stat_partitions.test

# The include statement below is a temp one for tests that are yet to
#be ported to run with InnoDB,
#but needs to be kept for tests that would need MyISAM in future.
--source include/force_myisam_default.inc

-- source include/have_ndb.inc

set @is_enable_default = @@global.ndb_index_stat_enable;

set @is_enable = 1;
source ndb_index_stat_enable.inc;

create table record_in_range(no int primary key auto_increment,
query varchar(256), part_count int, 
explain_rows int, count_rows int) engine = myisam;

CREATE TABLE t1(
  K INT NOT NULL AUTO_INCREMENT,
  I INT,
  J INT,
  L INT,
  PRIMARY KEY(K),
  KEY(I,J),
  KEY(L)
) ENGINE=ndbcluster
  partition by key (K) partitions 1;

INSERT INTO t1(I,J,L) VALUES
(1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5),
(6,6,6),(7,7,7),(8,8,8),(9,9,9),(0,0,0);

INSERT INTO t1(I,J,L) SELECT I,1,I FROM t1 ORDER BY K;
INSERT INTO t1(I,J,L) SELECT I,2,I FROM t1 ORDER BY K;
INSERT INTO t1(I,J,L) SELECT I,3,I FROM t1 ORDER BY K;
INSERT INTO t1(I,J,L) SELECT I,4,I FROM t1 ORDER BY K;
INSERT INTO t1(I,J,L) SELECT I,5,I FROM t1 ORDER BY K;
INSERT INTO t1(I,J,L) SELECT I,6,I FROM t1 ORDER BY K;
INSERT INTO t1(I,J,L) SELECT I,7,I FROM t1 ORDER BY K;
INSERT INTO t1(I,J,L) SELECT I,8,I FROM t1 ORDER BY K;
INSERT INTO t1(I,J,L) SELECT I,9,I FROM t1 ORDER BY K;

select i, count(*) from t1 group by 1 order by 1;
select l, count(*) from t1 group by 1 order by 1;

ANALYZE TABLE t1;

--disable_query_log
let $i = 10;
let $p = 1;
while ($i)
{
  --let $q=SELECT count(*) as Count FROM t1 WHERE i = $i
  --let $explain_type= query_get_value(EXPLAIN $q, type, 1)
  --let $explain_rows= query_get_value(EXPLAIN $q, rows, 1)
  --let $count_rows= query_get_value($q, Count, 1)
  --eval insert into record_in_range(query,part_count,explain_rows,count_rows) values ('$q',$p,$explain_rows,$count_rows);
  dec $i;
}

let $l = 10;
while ($l)
{
  --let $q=SELECT count(*) as Count FROM t1 WHERE l = $l
  --let $explain_type= query_get_value(EXPLAIN $q, type, 1)
  --let $explain_rows= query_get_value(EXPLAIN $q, rows, 1)
  --let $count_rows= query_get_value($q, Count, 1)
  --eval insert into record_in_range(query,part_count,explain_rows,count_rows) values ('$q',$p,$explain_rows,$count_rows);
  dec $l;
}

alter table t1 partition by key() partitions 8;
analyze table t1;

let $p = 8;
let $i = 10;
while ($i)
{
  --let $q=SELECT count(*) as Count FROM t1 WHERE i = $i
  --let $explain_type= query_get_value(EXPLAIN $q, type, 1)
  --let $explain_rows= query_get_value(EXPLAIN $q, rows, 1)
  --let $count_rows= query_get_value($q, Count, 1)
  --eval insert into record_in_range(query,part_count,explain_rows,count_rows) values ('$q',$p,$explain_rows,$count_rows);
  dec $i;
}

let $l = 10;
while ($l)
{
  --let $q=SELECT count(*) as Count FROM t1 WHERE l = $l
  --let $explain_type= query_get_value(EXPLAIN $q, type, 1)
  --let $explain_rows= query_get_value(EXPLAIN $q, rows, 1)
  --let $count_rows= query_get_value($q, Count, 1)
  --eval insert into record_in_range(query,part_count,explain_rows,count_rows) values ('$q',$p,$explain_rows,$count_rows);
  dec $l;
}

--enable_query_log

# Change sql_mode to allow the reporting query below
# which uses "DISTINCT with an ORDER BY on column which
# is not in the select list"
--source include/turn_off_only_full_group_by.inc

select distinct 
       substring(rr.query from INSTR(rr.query, 'WHERE')) as 'WHERE', 
       count_rows, 
       p1.val as p1_val, 
       if(p8.err_pct is not null and abs(p8.err_pct)<45,'-',p8.val) p8_val,
       case when p1.err_pct is null then '-' when abs(p1.err_pct)<45 then '<45' else p1.err_pct end p1_err_pct,
       case when p8.err_pct is null then '-' when abs(p8.err_pct)<45 then '<45' else p8.err_pct end p8_err_pct
from record_in_range rr,
     (select query, explain_rows as val, if(count_rows>0,floor(100*(explain_rows - count_rows) / count_rows),NULL) err_pct
      from record_in_range p where part_count = 1) p1,
     (select query, explain_rows as val, if(count_rows>0,floor(100*(explain_rows - count_rows) / count_rows),NULL) err_pct
      from record_in_range p where part_count = 8) p8
where rr.query = p1.query
  and rr.query = p8.query
order by rr.no;

--source include/restore_sql_mode_after_turn_off_only_full_group_by.inc

DROP TABLE t1, record_in_range;

--echo End of 5.1 tests

set @is_enable = @is_enable_default;
source ndb_index_stat_enable.inc;

Man Man