【发布时间】:2011-09-28 22:25:04
【问题描述】:
我有以下 MySql 表,其中包含我的原始事件数据(大约 150 万行)
userId | pathId | other stuff....
我在userId, pathId 上有一个索引(大约 50,000 个独特的组合)
在处理过程中,我确定了 30,000 个我不想要的 userId, pathId 值,但我确实想保留原始原始表。所以我想将所有行复制到一个已处理的事件表中,除了与这 30,000 个userId, pathId 值匹配的行。
我正在考虑的一种方法是将我不想要的行的 30,000 userId,PathId 值写入 temp_table,然后执行以下操作:
[create table processed_table ...]
insert into processed_table
select * from raw_table r
where not exists (
select * from temp_table t where r.userId=t.userid and r.pathId=t.pathId
)
对于信息,processed_table 通常最终大小是 raw_table 的一半。
无论如何,这似乎可行,但我的 SQL 技能有限,所以我的问题(最后)是 - 这是最有效的方法吗?
【问题讨论】:
标签: mysql sql performance