Mysql 将大型插入查询拆分为较小的部分

Mysql 将大型插入查询拆分为较小的部分,mysql,Mysql,我有一个非常大的INSERT查询,它将多个表中的数据合并到一个新表中 此查询在具有数十万行的表上运行,因此执行时需要很长时间 有没有一种方法可以把它分成更小的部分,因此它首先获取用于连接的表的前200个用户名HypeAuditor-h.username,然后进行插入,获取下一批200个用户名,依此类推 代码如下: INSERT INTO Kombiniert (username, fullname, followers_heepsy, followers_ninjaoutreach, follo

我有一个非常大的INSERT查询,它将多个表中的数据合并到一个新表中

此查询在具有数十万行的表上运行,因此执行时需要很长时间

有没有一种方法可以把它分成更小的部分,因此它首先获取用于连接的表的前200个用户名
HypeAuditor-h.username
,然后进行插入,获取下一批200个用户名,依此类推

代码如下:

INSERT INTO Kombiniert
(username, fullname, followers_heepsy, followers_ninjaoutreach, followers_average, engagement_heepsy, engagement_ninjaoutreach, engagement_hypeauditor, engagement_average, city, state, country, category1, category2, category3, category4, category5, category6, follower_interest1, follower_interest1_share, follower_interest2, follower_interest2_share, follower_interest3, follower_interest3_share, follower_country, follower_country_share, follower_country_total, follower_country_engaged)
    Select bb.*, follower_country_total*engagement_average as follower_country_engaged from
        (
            Select aa.*, followers_average*follower_country_share as follower_country_total from 
            (
                select 
                h.username,
                nj.fullname,
                hy.followers as followers_heepsy,
                nj.followers as followers_ninjaoutreach,
                case when hy.followers IS NULL AND nj.followers>0 THEN nj.followers
                when hy.followers>0 AND nj.followers IS NULL THEN hy.followers
                else (hy.followers+nj.followers)/2 end as followers_average,
                hy.engagement/100 as engagement_heepsy,
                nj.engagement/100 as engagement_ninjaoutreach,
                h.engagement/100 as engagement_hypeauditor,
                case    when hy.engagement IS NULL AND nj.engagement IS NULL AND h.engagement>0 THEN h.engagement/100
                        when hy.engagement IS NULL AND nj.engagement>0 AND h.engagement IS NULL THEN nj.engagement/100
                        when hy.engagement>0 AND nj.engagement IS NULL AND h.engagement IS NULL THEN hy.engagement/100
                        when hy.engagement IS NULL AND nj.engagement>0 AND h.engagement>0 THEN (h.engagement/100+nj.engagement/100)/2
                        when hy.engagement>0 AND nj.engagement>0 AND h.engagement IS NULL THEN (hy.engagement/100+nj.engagement/100)/2
                        when hy.engagement>0 AND nj.engagement IS NULL AND h.engagement>0 THEN (h.engagement/100+hy.engagement/100)/2
                        else (hy.engagement/100+nj.engagement/100+h.engagement/100)/3 end as engagement_average,
                nj.city,
                nj.state,
                nj.country ,
                nj.category_1,
                nj.category_2,
                nj.category_3,
                nj.category_4,
                nj.category_5,
                nj.category_6,
                h.interest1,
                h.Interest1_percentage/100 as follower_interest_share1,
                h.interest2,
                h.Interest2_percentage/100 as follower_interest_share2,
                h.interest3,
                h.Interest3_percentage/100 as follower_interest_share3,
                h.country as follower_country,
                h.country_percentage/100 as follower_country_share


                from HypeAuditor h
                left join Heepsy hy on h.username = hy.username
                left join NinjaOutreach nj on nj.username=h.username
                ) aa 
            ) bb

我不明白子查询的意义。如果你删除它们,也许插入操作已经足够好了。我看不出子查询的意义。如果删除它们,那么插入的性能可能已经足够好了。