我想用大量更新(约600个)填充数百万行的表。
我创建了一个表“ all_combinations ...”,其ID为(appln_id),其对应列的默认值为“ FALSE”。 接下来,我尝试更新约600个表中的列。只要“ all_combinations”中的ID与表之一中的ID相对应,相应的列就会设置为“ TRUE”。 600个表格名称对应于我要填写的600列,例如'A01C': 如果A01C可以与all_combinations联接,则应将A01C列设置为TRUE。 我已经运行此代码大约3天了。 有什么想法可以加快/改进代码吗?
create table all_combinations_ipc4_compr (
appln_id INT DEFAULT NULL,
a01b BOOLEAN DEFAULT FALSE,
a01c BOOLEAN DEFAULT FALSE,
a01d BOOLEAN DEFAULT FALSE,
a01f BOOLEAN DEFAULT FALSE,
a01g BOOLEAN DEFAULT FALSE,
a01h BOOLEAN DEFAULT FALSE,
a01j BOOLEAN DEFAULT FALSE,
a01k BOOLEAN DEFAULT FALSE,
a01l BOOLEAN DEFAULT FALSE,
a01m BOOLEAN DEFAULT FALSE,
a01n BOOLEAN DEFAULT FALSE,
a01p BOOLEAN DEFAULT FALSE,
... 600 variables
insert into all_combinations_ipc4_compr
select distinct appln_id from other_table;
-- millions of IDs!
update all_combinations_ipc4_compr t1 set a01b=TRUE from a01b t2 where t1.appln_id=t2.appln_id;
update all_combinations_ipc4_compr t1 set a01c=TRUE from a01c t2 where t1.appln_id=t2.appln_id;
update all_combinations_ipc4_compr t1 set a01d=TRUE from a01d t2 where t1.appln_id=t2.appln_id;
update all_combinations_ipc4_compr t1 set a01f=TRUE from a01f t2 where t1.appln_id=t2.appln_id;
update all_combinations_ipc4_compr t1 set a01g=TRUE from a01g t2 where t1.appln_id=t2.appln_id;
update all_combinations_ipc4_compr t1 set a01h=TRUE from a01h t2 where t1.appln_id=t2.appln_id;
update all_combinations_ipc4_compr t1 set a01j=TRUE from a01j t2 where t1.appln_id=t2.appln_id;
update all_combinations_ipc4_compr t1 set a01k=TRUE from a01k t2 where t1.appln_id=t2.appln_id;
update all_combinations_ipc4_compr t1 set a01l=TRUE from a01l t2 where t1.appln_id=t2.appln_id;
update all_combinations_ipc4_compr t1 set a01m=TRUE from a01m t2 where t1.appln_id=t2.appln_id;
update all_combinations_ipc4_compr t1 set a01n=TRUE from a01n t2 where t1.appln_id=t2.appln_id;
update all_combinations_ipc4_compr t1 set a01p=TRUE from a01p t2 where t1.appln_id=t2.appln_id;
update all_combinations_ipc4_compr t1 set a21b=TRUE from a21b t2 where t1.appln_id=t2.appln_id;
... 600 updates