mysql中,千万条级别的数据查询,关联其他表查询时,速度非常慢。
所查询表均已经建立索引。
最后亲测增加临时表的做法,速度增加上百倍。
sql优化前:
SELECT * from ent_credit_base_info t where t.ent_credit_sode in
(
SELECT DISTINCT ent_id from ent_medicine_retail_info
);
sql优化后:
SELECT * from ent_credit_base_info t where t.ent_credit_sode in
(
select ent_id from (
SELECT DISTINCT ent_id from ent_medicine_retail_info
)as tmp
);
----------
mysql数据库手工导入命令 :
mysql进入,
use databasename
执行命令:
LOAD DATA LOCAL INFILE 'C:\\5.txt' INTO TABLE tablename;
效能一级棒。
导入txt如果出现,invalid utf8 character string 错误,需要将txt文件重新保存,并选择字符格式未utf8