联接查询的问题
时间:2011-07-26
来源:互联网
             菜鸟请教:
有两个表 t_table1,t_table2 从 表t_table1 中 找出 t_table2中col_other 大于0的列 下面两个语句有啥性能的区别,为啥?
两个表都超过10万行
SQL code
测试了下 下面的语句 为啥 第二条列上加表名的语句查询时间快 和不加的不是一个数量级
SQL code
            有两个表 t_table1,t_table2 从 表t_table1 中 找出 t_table2中col_other 大于0的列 下面两个语句有啥性能的区别,为啥?
两个表都超过10万行
SQL code
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;
测试了下 下面的语句 为啥 第二条列上加表名的语句查询时间快 和不加的不是一个数量级
SQL code
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;
作者: baggio1984 发布时间: 2011-07-26
             第二条不是快,应该是缓冲了。            
            作者: ACMAIN_CHM 发布时间: 2011-07-26
 相关阅读 更多  
      
    热门阅读
-  
 office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
          阅读:74
 -  
 如何安装mysql8.0
          阅读:31
 -  
 Word快速设置标题样式步骤详解
          阅读:28
 -  
 20+道必知必会的Vue面试题(附答案解析)
          阅读:37
 -  
 HTML如何制作表单
          阅读:22
 -  
 百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
          阅读:31
 -  
 ET文件格式和XLS格式文件之间如何转化?
          阅读:24
 -  
 react和vue的区别及优缺点是什么
          阅读:121
 -  
 支付宝人脸识别如何关闭?
          阅读:21
 -  
 腾讯微云怎么修改照片或视频备份路径?
          阅读:28
 















