Home > Database > Mysql Tutorial > MySQL 大DML操作建议

MySQL 大DML操作建议

WBOY
Release: 2016-06-07 17:31:07
Original
1064 people have browsed it

㈠ 大数据量INSERT ⑴ 使用多行插入代替单行:insert into t values (),(),(),... ⑵ LOAD DATA INFILE ... INTO TABLE t ⑶ 写

 ㈠ 大数据量INSERT

⑴ 使用多行插入代替单行:insert into t values (),(),(),...

⑵ LOAD DATA INFILE ... INTO TABLE t

⑶ 写入临时表、在 INSERT ... SELECT

⑷ 取消索引、约束,等数据加载完后在重建

⑸ INSERT时指定DELAYED属性

⑹ 对于InnoDB、可以分散INSERT到多个事务、批量提交

㈡ 大数据量UPDATE

这之前也应该disable掉索引和相关约束

① SELECT 唯一字段,变更字段

② 把结果集写入临时表

③ 为临时表创建复合索引

④ 循环临时表的每条记录

⑤ 依据临时表的唯一字段、更新目标表的变更字段

㈢ 大数据量DELETE

① 分区表

② 先把需要删除的数据的唯一标识取到临时表、游标循环批量delete

推荐阅读:

PL/SQL“ ORA-14551: 无法在查询中执行 DML 操作”解决

MySQL常用DDL、DML、DCL语言整理(附样例)

Oracle基本事务和ForAll执行批量DML练习

Oracle DML语句(insert,update,delete) 回滚开销估算

linux

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template