首页 > 编程 > Java > 正文

Javaweb开发后台使用sql查询效率问题

2019-11-08 20:43:53
字体:
来源:转载
供稿:网友

今天在项目中遇到了一个不算是问题的问题 后台查询地区时sql是这样的

String sql="select * from area_info_table where id in ("+ "select area_id from showroom_info_table where id in("+ "select showroom_id from release_showroom_table where content_id="+ids+ ")"+ ")";

由于地区表数据量较大查询要花费很长时间后来经理把sql优化了一下写成这样子

select t.* from area_info_table t ,showroom_info_table tt,release_showroom_table ttt where t.id=tt.area_id and tt.id =ttt.showroom_id  and  ttt.content_id="+ids+";

查询效率明显提高了 涨姿势了!!!


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表