性能批量加载从XML文件到MySQL的数据(Performance bulk-loading data from an XML file to MySQL)

将80GB的XML数据导入MySQL需要5天以上才能完成吗?

我目前正在导入一个大小约为80GB的XML文件,我正在使用的代码就在这个要点中 ,虽然一切正常,但它已连续运行了近5天,甚至还没有完成......

平均表大小大致为:

Data size: 4.5GB
Index size: 3.2GB
Avg. Row Length: 245
Number Rows: 20,000,000

如果需要更多信息,请告诉我!

服务器规格:

请注意,这是一个linode VPS

英特尔至强处理器L5520 - 四核 - 2.27GHZ 4GB总拉姆

XML示例

https://gist.github.com/2510267

谢谢!


在研究了关于这个问题的更多内容之后,这似乎是平均的,我发现这个答案描述了提高进口率的方法。


Should an import of 80GB's of XML data into MySQL take more than 5 days to complete?

I'm currently importing an XML file that is roughly 80GB in size, the code I'm using is in this gist and while everything is working properly it's been running for almost 5 straight days and its not even close to being done ...

The average table size is roughly:

Data size: 4.5GB
Index size: 3.2GB
Avg. Row Length: 245
Number Rows: 20,000,000

Let me know if more info is needed!

Server Specs:

Note this is a linode VPS

Intel Xeon Processor L5520 - Quad Core - 2.27GHZ 4GB Total Ram

XML Sample

https://gist.github.com/2510267

Thanks!


After researching more regarding this matter this seems to be average, I found this answer which describes ways to improve the import rate.

2022-05-13 19:05

满意答案

有一件事有助于提供更多的事情,而不是每次一次。 我建议从每几百行开始一次提交,然后从那里调整。

此外,你正在做的事情,你做存在检查 - 转储; 它大大增加了您需要运行的查询数量。 相反,使用ON DUPLICATE KEY UPDATE (MySQL扩展,而不是标准兼容)来使重复INSERT自动执行正确的操作。

最后,考虑构建工具以将XML转换为适合与mysqlimport工具一起使用的文本形式,并使用该批量加载器。 这将干净地将XML解析所需的时间与数据库摄取所需的时间分开,并且还通过使用为此目的设计的工具来加速数据库导入本身(而不是INSERTUPDATE命令, mysqlimport使用专门的LOAD DATA INFILE扩展)。


One thing which will help a great deal is to commit less frequently, rather than once-per-row. I would suggest starting with one commit per several hundred rows, and tuning from there.

Also, the thing you're doing right now where you do an existence check -- dump that; it's greatly increasing the number of queries you need to run. Instead, use ON DUPLICATE KEY UPDATE (a MySQL extension, not standards-compliant) to make a duplicate INSERT automatically do the right thing.

Finally, consider building your tool to convert from XML into a textual form suitable for use with the mysqlimport tool, and using that bulk loader instead. This will cleanly separate the time needed for XML parsing from the time needed for database ingestion, and also speed the database import itself by using tools designed for the purpose (rather than INSERT or UPDATE commands, mysqlimport uses a specialized LOAD DATA INFILE extension).

相关问答

更多

MySQL:从非常格式化的XML文件中提取数据(MySQL: Extracting data from an unusually formatted XML file)

考虑一下XSLT ,它很像SQL,它是一种声明性的专用语言,但旨在将XML源转换为特定格式,如MySQL的LOAD XML方法所需的XML 。 XSLT可以通过命令行运行Bash / Powershell,任何通用语言(Java,C#,PHP,Perl,Python,R,VB), Saxon / Xalan等专用处理器,甚至是日常Excel! 实际上,您甚至可以通过向终端发送shell命令直接从MySQL的命令行客户端运行XSLT。 这是一个xsltproc (可用于Linux / Mac的处理器...

如何从php和mysql制作xml文件(How to make xml file from php and mysql)

也许会经历 http://library.creativecow.net/articles/brimelow_lee/php_mysql/video-tutorial.php 会为你清理事情。 但是,使用它只是为了理解XML的概念以及它与mysql,php和swf的关系。 对于实际工作,请查看处理XML的库,例如AvatarKava的答案中提到的序列化器。 Maybe going through http://library.creativecow.net/articles/brimelow_le...

性能批量加载从XML文件到MySQL的数据(Performance bulk-loading data from an XML file to MySQL)

有一件事有助于提供更多的事情,而不是每次一次。 我建议从每几百行开始一次提交,然后从那里调整。 此外,你正在做的事情,你做存在检查 - 转储; 它大大增加了您需要运行的查询数量。 相反,使用ON DUPLICATE KEY UPDATE (MySQL扩展,而不是标准兼容)来使重复INSERT自动执行正确的操作。 最后,考虑构建工具以将XML转换为适合与mysqlimport工具一起使用的文本形式,并使用该批量加载器。 这将干净地将XML解析所需的时间与数据库摄取所需的时间分开,并且还通过使用为此目...

SQLite是否支持批量加载(sort-then-indexing)?(Does SQLite support bulk-loading (sort-then-indexing)?)

批量加载要求数据已经排序。 SQLite通过将行插入临时索引来实现排序,因此将其用于批量加载不会很有成效。 Bulk loading requires that the data is already sorted. SQLite implements sorting by inserting the rows into a temporary index, so using it for bulk loading would not be productive.

MySQL LOAD XML导入性能(MySQL LOAD XML import performance)

解决方案是使用LOAD DATA INFILE而不是LOAD XML INFILE,这似乎在所有MySQL版本中都存在严重的性能问题。 见评论。 这个改变对我来说不是一个大问题,因为我正在使用XSLT来创建输入文件。 XML本来会更简单,更灵活,但XSLT也允许创建纯文本输出(CSV / TSV)。 The solution was to use LOAD DATA INFILE and not LOAD XML INFILE, which seems to suffer from severe ...

XML PHP MYSQL数据解析(XML PHP MYSQL data parsing)

这只是一个例子,它的工作原理如图所示.. Spoonfeeding不好,所以你试着用这段代码探索更多.. <?php $xml=' <ALLIMAGES> <gal> <imageid>6</imageid> <imagetype>Vector</imagetype> <image>..images/accept.png</image> <companyname>w845</companyname> <descripti...

可以加载文件中的数据(mysql bulk uploads)读取压缩文件?(Can load data in file(mysql bulk uploads) read compressed files?)

你应该明确地使用LOAD DATA INFILE来做到这一点。 插入可能比LOAD DATA INFILE慢一个数量级,特别是在较大的文件上。 不幸的是,MySQL本身并不支持直接加载压缩文件(据我所知,任何类型)。 但是,如果您查看上面的LOAD DATA INFILE链接,则可以直接从管道将数据加载到表中(只需在页面中搜索“管道”)即可。 我想你可以使用该方法解压缩文件并将输出传输到MySQL,但压缩/解压缩显然比直接加载未压缩文件要慢。 You should DEFINITELY be us...

在SSIS包中批量加载XML文件时出错(Error bulk loading XML file in SSIS package)

这是操作系统问题 - 错误3.路径不存在。 请参阅系统错误代码页面 。 请检查文件的完整路径。 访问问题将出现错误代码5。 另外,这取决于谁在执行SSIS包。 您是否使用登录名从服务器执行此操作? 您是否在该凭证下从SQL Agent运行包? 你是否在工作中将运行改为凭证。 就像有人说的那样,尝试手动执行它。 如果失败,那么它就是存储过程代码。 如果它通过,那么它是从SSIS传递给SP的路径。 确保你知道你的工作目录是什么。 告诉我你是怎么做出来的。 That was a very mislead...

批量数据插入php mysql速度(Bulk data insert php mysql speed)

将您的数据分成块,可以是每个块的记录数(我更喜欢这个),或者将数据分成n组,然后进行批量插入,例如 INSERT INTO `table_name` (id, ref, link) VALUES (NULL, '{$sql_refid}', '{$sql_link}') , (NULL, '{$sql_refid}', '{$sql_link}') , (NULL, '{$sql_refid}', '{$sql_link}') , (...

相关文章

更多

(二)solr data import

solr 的 data import 导入 mysql数据 (1)、编辑 example/solr/c ...

Becoming a data scientist

Data Week: Becoming a data scientist Data Pointed, ...

移动MM failed to find resource file{mmiap.xml}

原地址:http://blog.csdn.net/alking_sun/article/details ...

MySQL 5.6 my.cnf 配置文件详解

MySQL 5.6 my.cnf 配置文件详解,很详细,可以直接复制使用 [client]port ...

无法启动Hbase hbase-default.xml file seems to be for and old version of HBase

无法启动Hbase 错误如下 Exception in thread &quot;main&quot; ...

高性能MYSQL的构架与相关软件介绍

文章来源:http://www.linuxidc.com/Linux/2011-08/40601.ht ...

data-config

Data-config为solr的data-import处理器配置数据来源。 依次按照如下树状结构: ...

用‘button’跟‘text’组合代替‘file’,选择文件后点‘submit’,‘file’的值被清空

各位大虾晚上好,我有个问题想请教你们,我想美化html的file外观,但貌似现在还不能用css直接设计 ...

《Big Data Glossary》笔记

清明假期翻以前的笔记发现有一些NoSQL相关的内容,比较零散,是之前读《Big Data Glossa ...

最新问答

更多

绝地求生、荒野行动、香肠派对 哪个更好玩???(都是吃鸡类游戏)

PC上的绝地求生,是最早也是最火的大逃杀游戏。 荒野行动是网易抄袭蓝洞绝地求生制作的手游。相似度90%,还有他一起出的终结折2,这2款正在被蓝洞告,打官司呢。 手游上的绝地求生有2部都是蓝洞授权(收钱)给腾讯开发的正版ID手游。所以跟PC上做的一模一样,蓝洞也没话说。 加上吃鸡国服也是腾讯独家代理,所以根本没有什么可说的。只要这个类型的 过于相似的,腾讯都可以借蓝洞之手起诉。打压同行是国内BAT最爱干的事嘛! 香肠派对画风虽然不一样,但核心玩法还是跟人家正版的一样的,同样也是没有被授权的。 98

如何在jQuery集合中选择第n个jQuery对象?(How to select the nth jQuery object in a jQuery collection?)

你可以使用eq : var rootElement = $('.grid').find('.box').eq(0); rootElement.find('.a'); /* Use chaining to do more work */ You can use eq: var rootElement = $('.grid').find('.box').eq(0); rootElement.find('.a'); /* Use chaining to do more work */

ASP NET使用jQuery和AJAX上传图像(ASP NET upload image with jQuery and AJAX)

您可以自己手动设置FormData键和值。 Upload 创建FormData并设置新的键/值 $("#btnUpload").on("click", function(e) { e.preventDefault(); var file = $("#imguploader").get(0).file

SQL Server XML查询中包含名称空间的位置(SQL Server XML query with namespaces in the where exist)

您可能希望使用#temp.identXml.query而不是#temp.identXml.query 。 您可以在这里阅读更多相关信息SQL Server XML exists() 我相信你也可以像这样使用它 Select #temp.identXml.value('(/*:PersonIdentity/*:MasterIndexes/*:PersonIndex/*:SourceIndex)[1]','varchar(100)') as Ident ,#temp.identXml.value(

宁夏银川永宁县望远镇哪里有修mp5的?

胜利街有家电维修,电脑城,银川商场多得很…

我想用更新的日期标记所有更新的行(I would like to mark all updated rows with the date that they have been updated)

您可以使用更新后触发的触发器来执行此操作。 给出如下表: create table your_table (id int primary key, val int, last_update datetime) 每当您更新表中的内容时,此触发器将设置last_update值。 CREATE TRIGGER trigger_name ON your_table AFTER UPDATE AS BEGIN UPDATE your_table SET your_ta

郑州会计培训班

招生的,至于时间吗,就看你自己的时间段了,你可以致电0371-63300220.他们会帮你选择一下的。离你最近,最专业的培训班。

如何定位数组中的负数,并得到所有正数的总和?(How to target e negative number from an array, and get the sum of all positive numbers?)

只需创建一个条件来检查它是正数还是负数,然后定义一个空的数组negatives ,如果数字是负数,则将其推到负数组中,如果是正数,则将其添加到sum变量中,请查看下面的工作示例。 function SummPositive( numbers ) { var negatives = []; var sum = 0; for(var i = 0; i < numbers.length; i++) { if(numbers[i] < 0) { negati

在响应图像上叠加网格(Overlay grid on responsive image)

使用两个linear-gradient s,我们可以创建两个简单的线条,然后每隔n%重复一次background-size 。 它看起来像这样: background: linear-gradient(to bottom, #000 2px, transparent 2px), linear-gradient(to right, #000 2px, transparent 2px); background-size: 10%; 两个渐变创建两条相交的线,长度为百分比,如下所示: 使用默认的b

无法让POST在Azure网站上运行(Could not get POST to work on Azure Website)

最后我找到了答案......我不得不删除尾随的斜线! 我使用了“ https://example.com/api/messages/ ”,这将自动产生GET,无论我使用PostAsync还是PostAsJsonAsync。 使用“ https://example.com/api/messages”,GET和POST似乎都运行良好! Finally I've found the answer.... I had to remove the trailing slash! I've used "ht