在mysql中,我有两个表,表A和表B,数量级都是亿级,存储引擎是brighthouse。两表做连接的时间是10秒左右,可是如果要使用select into outfile就完了,limit20条数据后,需要十多分钟。有哪位有经验的人,可以说说为什么效率会下降这么快。我对于这两个表单独每个表做select into outfile 时间也不过十多分钟。
就是简单的select * from A,B where A.id = B.id limit 20 into outfile 'file_name'
select * from A,B where A.id = B.id limit 20直接执行这句看耗时是多少?如果很长,则show index from a; show index from b; explain select * from A,B where A.id = B.id limit 20 出来分析一下。
就是简单的select * from A,B where A.id = B.id limit 20 into outfile 'file_name'
show index from b;
explain select * from A,B where A.id = B.id limit 20 出来分析一下。
如果直接执行select语句,执行的效率很高,也就8秒10秒左右。