mysql 数据库大数据量查询

时间:2022-11-05 11:40:06

 select count(id) from log_pv where (issue_id=1042 or issue_id=1044 ) and  exists (select ip from t_ipnetlist where log_pv.ip=t_ipnetlist.ip)

 

select count(id) from log_pv where (issue_id=1042 or issue_id=1044 ) and  log_pv.ip in (select ip from t_ipnetlist )

 

select count(id) from log_pv as t1 INNER JOIN  t_ipnetlist as t2 on  t1.ip=t2.ip where t1.issue_id=1042 or t1.issue_id=1044

 

in数据量少效率还可以,数据量大就效率低
exists的效率依赖于匹配度。
inner join效率比较稳定。

 

insert into table() select * from table