简体   繁体   English

MySQL与MS SQL Server —进行插入/更新的并行进程

[英]MySQL vs MS SQL Server — parallel processes doing insert/ updates

I'm using a 3rd party ETL application (Pentaho/ Kettle/ Spoon) --- so unfortunately I'm not sure of the exact SQL query, but I can try different manual queries. 我正在使用第三方ETL应用程序(Pentaho / Kettle / Spoon)---不幸的是,我不确定确切的SQL查询,但是我可以尝试其他手动查询。

I'm just wondering why ... MySQL seems to allow multiple processes at once do an insert, but if found, update ... queries. 我只是想知道为什么... MySQL似乎一次允许多个进程进行插入,但是如果找到,则更新...查询。

MS SQL does not ... it "locks" the rows when one query is doing an insert/ update ... and throws an error if another query tries to insert/ update over the same data. MS SQL不会...当一个查询正在执行插入/更新时...会“锁定”行...如果另一个查询尝试对同一数据进行插入/更新,则会引发错误。

I guess this makes sense ... but I'm just a bit annoyed that MySQL allows this, and MS SQL does not. 我想这是有道理的...但是我有点烦恼MySQL允许这样做,而MS SQL不允许。

Is there any way to get around this? 有什么办法可以解决这个问题?

I just want as fast a way as possible to insert/ update a list of 1000 records into a data table. 我只是想尽可能快地将1000条记录的列表插入/更新到数据表中。 In the past I just divided this numbers into 20 processes updating 50 records doing insert/ updates ... this worked in parallel because none of the 1000 records are duplicate ... they are only some duplicates of them already in table ... so they can be inserted/ updated in any order, so long as it happens. 在过去,我只是将这个数字分为20个进程,更新50个记录进行插入/更新……这是并行进行的,因为1000条记录中没有一个是重复的……它们只是表中已经存在的一些重复……所以只要它们发生,它们可以以任何顺序插入/更新。

Any thoughts? 有什么想法吗? Thanks 谢谢

MySQL use the ISAM storage engine by default which does not support transactions. MySQL默认使用不支持事务的ISAM存储引擎。 SQL Server is a RDBMS and supports transactions as you've observed though you can tweak the isolation levels to do risky things like read uncommitted (very rarely a good idea). SQL Server是RDBMS,它支持事务,尽管您可以调整隔离级别来做一些危险的事情,例如未提交读(很少是个好主意)。

If you want your MySQL database to have transaction support, you need to explicitly create your table with the option ENGINE=INNODB. 如果希望MySQL数据库具有事务支持,则需要使用ENGINE = INNODB选项显式创建表。 Older versions also support ENGINE=BDB which is the Berkeley Database engine. 较旧的版本还支持ENGINE = BDB,这是Berkeley数据库引擎。 See MySQL docs for more details on InnoDB http://dev.mysql.com/doc/refman/5.7/en/innodb-storage-engine.html 有关InnoDB的更多详细信息,请参见MySQL文档http://dev.mysql.com/doc/refman/5.7/en/innodb-storage-engine.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM