复杂的SQL语句是改为执行多条效率快,还是执行一条效率快

2019-10-30 20:38发布

我要统计数据库表15张表的条数,以下两种方案哪个执行的快一些:
方案一:
执行15次统计SQL:
select count(1) from 表1 where条件
select count(1) from 表2 where条件
.........
select count(1) from 表15 where条件

方案二:
使用一条SQL一下子统计出15张表的条数:
select
(select count(1) from 表1 where条件) t1_count,
(select count(1) from 表2 where条件) t2_count,
........
(select count(1) from 表15 where条件) t15_count,

标签: java cmd gpg
1条回答
该账号已被封号
2楼-- · 2019-10-30 21:08

有什么问题吗?

查看更多
登录 后发表回答