0

Might seem a strange question but would there be a performance benefit in using XML for a database rather than MySQL and tables?

To put this into context I wil be creating a website that has user profiles. I know more XML than MySQL and know most ppl will use MySQL as standard but was wondering if anyone could throw some pennies this way about how the two compare and if this suggestion is as outrageous to anyone understanding what the big O notation is as it could be...

2
  • pardon me if I sound naive, but how would you query an XML database? Commented Jun 1, 2012 at 21:31
  • thats exactly what I have just been thinking - I suppose it would be a search of the XML file for tag names which would be a serial search... Commented Jun 1, 2012 at 21:35

5 Answers 5

2

The bigger xml file, the more memory usage because you'll have to load the entire xml file to RAM whilst running your script. An average MySQL database is about 4mb big. Lets take that to a xml file of 4 mb, loaded to ram 4 mb, loaded from disk, into ram at every pageview, with about 25 visitors at any given moment that's 100mb already lost, let's say they flick a lotthrough pages it adds up to a fast 1 gigabyte of ram. Not to mention you'll add about 1 second to page load every time, if not longer. Not to mention continueus disk load for reading and writing changed vars. Threaded fork issues when two vitors want to update the same xml file.

These problems you don't have with an SQL server.

Sign up to request clarification or add additional context in comments.

4 Comments

thanks, thats the kind of example I was looking for....how does the MySQL file get read and loaded each time and how does that impact RAM usage?
Well, a lot more efficient. MySQL also has a lot of load balancing and keeping impact low. You'd have to dive into how they set it up, but my sql databases of 300mb don't take up that much ram, but respond lightning fast to complex queries, way faster than an error prone xml file for which I'd completely had to write a read write, fetch, compare, join framework from scratch to get the data that MySQL gives out of te box.
cool thanks - can I apply codd's normalization to MySQL tables? I will look it up but not too sure if I can link field values to other tables....?
You could use joins. if time is the same, or user is the same, etc. if they have matching values yoyu can join them in various ways
0

MySQL has indexes, and it's optimized for the binary values you will be storing. All you have with an xml file, is a plain file.. and any optimizations (caching, indexing, anything you can think of) will be up to you to implement.

XML is a great format for transport, everybody speaks it.. but you do not want to use it for storage.

And if you already know XML, but not yet MySQL.. I would say you're ahead of the game. You'll probably find writing SQL queries and fetching the results more straightforward than working with xml data.

Comments

0

As I see - there are several XML Db solutions available - these appear in a simple google search:

http://exist-db.org/exist/index.xml;jsessionid=1dowedwdr9hsanbcvdcom8aka

http://basex.org/

http://www.oracle.com/technetwork/database/features/xmldb/index.html

http://www.sedna.org/

So all it matters here is the speed of development. If you're mostly familiar with XML - then using one of those could be a booster for development time. However - there is plenty of relational DB ORM products - depending on the programming language, that leverage the most dev effort and make it easy to use a database for a web site. So if you don't have some specific needs for your web site, you might go with any of the options above.

Comments

0

It depends on the structure of your database. This question cann't give a definite answer without knowing anything about your data. Any comparison of XML versus a relational database depends heavily on which data you choose, and what type of operations you plan.

For example you want store, index, and query is more than million rows and each row has a lot of the same fields. That’s a simple and fixed structure and it’s the same for all records. It’s a perfect fit for a relational database and can be stored in a single table. Relational databases handles such fixed records very efficiently.

Comments

0

Well, there are two main questions here.

First, if you're going to use a database, you have a choice between an XML database and a relational database. The choice depends primarily on the nature of your data (especially its complexity, but also the way in which it is used).

Then you have the choice between using a database and using a simple file (for example an XML file). That choice depends primarily on the quantity of data and the transaction throughput.

Since you haven't told us much about the nature of the data or its quantity or the throughput requirements, it's hard to advise you specifically on either question.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.