菜鸟请教:有两个表 t_table1,t_table2 从 表t_table1 中 找出 t_table2中col_other 大于0的列 下面两个语句有啥性能的区别,为啥?
两个表都超过10万行create table t_table1
(
key_col bigint not null auto_increment,
index_col bigint not null,
col_1 int not null,
col_2 int not null,
primary key(key_col)
)engine = innodb;create index index_name on t_table1(index_col);create table t_table2
(
key_col bigint not null auto_increment,
index_col bigint not null,
col_other int not null,
primary key(key_col)
)engine = innodb;create index index2_name on t_table2(index_col);select col_1, col_2 from t_table1, t_table2 where t_table2.col > 0 and t_table1.index_col = t_table2.index_col;select col_1, col_2 from t_table1 right join t_table2 on t_table1.index_col = t_table2.index_col where t_table2.col_other > 0;
测试了下 下面的语句 为啥 第二条列上加表名的语句查询时间快 和不加的不是一个数量级select col_1, col_2 from t_table1, t_table2 where t_table2.col > 0 and
t_table1.index_col = t_table2.index_col;select t_table1.col_1, t_table1.col_2 from t_table1, t_table2 where t_table2.col > 0 and
t_table1.index_col = t_table2.index_col;
两个表都超过10万行create table t_table1
(
key_col bigint not null auto_increment,
index_col bigint not null,
col_1 int not null,
col_2 int not null,
primary key(key_col)
)engine = innodb;create index index_name on t_table1(index_col);create table t_table2
(
key_col bigint not null auto_increment,
index_col bigint not null,
col_other int not null,
primary key(key_col)
)engine = innodb;create index index2_name on t_table2(index_col);select col_1, col_2 from t_table1, t_table2 where t_table2.col > 0 and t_table1.index_col = t_table2.index_col;select col_1, col_2 from t_table1 right join t_table2 on t_table1.index_col = t_table2.index_col where t_table2.col_other > 0;
测试了下 下面的语句 为啥 第二条列上加表名的语句查询时间快 和不加的不是一个数量级select col_1, col_2 from t_table1, t_table2 where t_table2.col > 0 and
t_table1.index_col = t_table2.index_col;select t_table1.col_1, t_table1.col_2 from t_table1, t_table2 where t_table2.col > 0 and
t_table1.index_col = t_table2.index_col;
用这条语句查询 经常出现 mysql客户端没有响应 用别的终端登上去 发现 查询的线程已经是sleep了 这是什么问题? max_packet_size 设置的是 32M