doulu7921 2013-02-14 09:05
浏览 42
已采纳

这三个选项中哪一个最快填充我的数据库表?

I have a (huge: 6.4 million rows) database table with three columns as follows:

URL     Title      Description

Right now only the URL column is populated, with various urls from around the web. I have to add a title and meta description to the url in each row. There are three ways I see I can do this:

Option 1: Use php and CURL to go to each url and grab the title and meta:description. (Even with using options 2 or 3 I'll have to do this for at least part of the urls).

Option 2: I have a DMOZ xml file which has several million elements which look like this:

    <ExternalPage about="http://animation.about.com/">
       <d:Title>About.com: Animation Guide</d:Title>
       <d:Description>Keep up with developments in online animation for all skill levels.     Download tools, and seek inspiration from online work.</d:Description>
       <topic>Top/Arts/Animation</topic>
    </ExternalPage>
    <ExternalPage about="http://www.toonhound.com/">
       <d:Title>Toonhound</d:Title>
       <d:Description>British cartoon, animation and comic strip creations - links, reviews  and news from the UK.</d:Description>
       <topic>Top/Arts/Animation</topic>
    </ExternalPage>

etc.

I can use xmlreader to compare the url in every ExternalPage-about to see if it matches one of the 6.4 million urls in my table, and if it does, add the title and description.

Option 3: I can write all the above dmoz data into a separate database table (again using xmlreader), which will also take time, and then somehow use JOINs and SELECTs on the two tables to get the information I need.

Would option 2 or 3 be quicker for those urls than just using option 1 for all the urls? If yes, which of the two options would be faster?

  • 写回答

2条回答 默认 最新

  • dsfhe34889 2013-02-14 09:29
    关注

    Assuming "Faster" means less time to update your URL table, then option 3 seems to be the best option.

    You can populate another table with records from XML and then using JOIN to update your main table.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?