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

javaweb开发后台使用sql查询效率问题。今天在项目中遇到了一个不算是问题的问题 后台查询地区时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+”;

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

(0)
上一篇 2022年3月21日
下一篇 2022年3月21日

相关推荐