在MySQL中更新记录的最佳方式来自XML feed [英] The best way of update records in MySQL from XML feed

查看:97
本文介绍了在MySQL中更新记录的最佳方式来自XML feed的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在考虑最好的方式,如何从XML Feed中更新我的表(MySQL)记录。我有数据库,这个数据库包含来自几个销售门户的每日优惠。
所以现在 - 大约午夜我删除我的表中的所有记录(因为我认为最好删除表中的所有内容,而不是比较当前数据与插入)和使用脚本(运行CRON)我从门户下载新的优惠(通过它们的XML馈送)。这种方式有一个缺点 - 删除旧的和插入新记录之间的时间间隔是大约5分钟 - 通过这5分钟是表空。

I am thinking about the best way, how to update my records in table (MySQL) from XML feed. I have database and this database contains the daily offers from several sales portals. So now - about midnight I am deleting all records from my table (because I think is better delete everything from table than comparing currently data with inserted) and with using script (run of CRON) I am downloading new offers from portal (by their XML feeds). This way have one disadvantage -- the time interval among deleting old and inserting new records is ca 5 minutes -- and through this 5 minutes is table empty.

喜欢问你,如果你能帮助我更好的方式,如何更新记录在我的表使用更好的方法...

And I would like to ask you, if you could help me with some better way, how updating records in my table using better way...

非常感谢你的时间! / p>

Thanks a lot for your time!

推荐答案

我会将新的xml feed导入一个临时表,然后当所有导入成功时,您可以简单地删除原始表并将新的重命名为原始。这将导致更少的停机时间,但更重要的是,它会让你能够在新的XML导入失败的情况下中止切换。

I would import the new xml feeds into a temporary table, keeping the old table active; and then when all imports are successful, you can simply drop the original table and rename the new to be the original. This should result in less downtime, but more importantly it will give you the ability to abort the switch in the event the new import of XML fails on a given night.

希望这有助于。

这篇关于在MySQL中更新记录的最佳方式来自XML feed的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆