dsq30861 2014-08-16 12:19
浏览 60
已采纳

哪个更快:从XML文件或MySQL表中读取数据?

I have an XML file which has 2 pieces of information:

  1. Watch world cup on Youtube
  2. Go for a drink at Bedroom club

Which the order of the tags are: "Watch" and "Go" tags are parent tags, "world cup on" and "for a drink at" are children tags and "Youtube" and "Bedroom club" are children tags of the previous ones.

And I also got a database which has the same information as in that structure:

  • 1st column:act_style(Watch/Go)
  • 2nd column:act_desc (world cup on/for a drink at)
  • 3rd column:act_page (Youtube/Bedroom club)

So my question is which of these pieces of information does PHP get faster or does it get them in the same time?

  • 写回答

1条回答 默认 最新

  • duandi4238 2014-08-16 13:11
    关注

    What I think you meant here is a "relational" data base that can be accessed with SQL. The intent of XML is to store data in a flat file, humanly readable, easily accessible form. Methods for accessing an XML data "store" are quite robust and evolving all the time, to include a proposal from Microsoft for "XQL" - an SQL equivalent designed to manipulate XML data stores.

    In XML data storage, the data is stored in a file which represents an XML Schema of the data. To read the data, you have to pull and open the entire file in memory and use techniques like xpath to get the data element you want. In SQL data storage, the data is stored in a database ( usually relational database). To read the data, you simple sent an SQL query to the database. The database management engine analysis the query and get the required data elements you ask for in your query which is finally sent to you as a reply.

    SQL is flexible and easy to use. Even on the text console only a few lines of code are enough to do complex data base queries.

    I see in this situation SQL would be better.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
  • ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)
  • ¥50 mac mini外接显示器 画质字体模糊
  • ¥15 TLS1.2协议通信解密
  • ¥40 图书信息管理系统程序编写
  • ¥20 Qcustomplot缩小曲线形状问题
  • ¥15 企业资源规划ERP沙盘模拟
  • ¥15 树莓派控制机械臂传输命令报错,显示摄像头不存在
  • ¥15 前端echarts坐标轴问题
  • ¥15 ad5933的I2C