garry towel
garry towel

Reputation: 59

Which is faster: read data from an XML file or from a MySQL table?

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:

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

Upvotes: 1

Views: 1139

Answers (1)

yakob abada
yakob abada

Reputation: 1287

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.

Upvotes: 3

Related Questions