我要统计数据库表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,
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/2310/viewspace-3139078/ ,如需转载,请注明出处,否则将追究法律责任。