473,382 Members | 1,464 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Better to search through lots of xml files in db or create search fields?

7
I'm not sure where to post this question, so sorry if it's in the wrong place. I have a design related question relating to xml files stored in a mysql database. I was wondering how some of you guys would approach this scenario.

Say you have 100 different products and each product is represented by a separate xml file that is stored in a database (mysql) and you want to perform general searches on information that is in the xml files. Would you loop through all of the xml files in the database to retrieve the results (seems very slow and performance heavy) or would create new fields in the database table to be used as search fields (redundant data as some is in search fields and some is in xml file)? Or, is there a better way to do this? I'm kind of new to xml so I really want to learn how to use it, any help is appreciated, thanks.
May 25 '07 #1
2 1506
chobo
7
I can never find any answers when it comes to xml and databases, so I did some testing on my own. I'll save other people the trouble and post my results.

Summary
Mysql is much faster then using xml files (duh), even with a 100 separate files you really notice the slowdown. By putting each product in it's own xml file speeds things up by about 3x, but it is still too slow to replace a database.

Disclaimer
These tests are not perfect, but the results differ so much it's easy to come to a conclusion.

Why run the tests?
Because no one seems to want to discuss or talk about how xml actually can be used to replace a database like mysql, but they advocate it. Xml has its uses and I am finding new ones all the time for websites, but using it to replace a mysql database for something as small as 100 records is not a good idea. Try using it for site navigation, it works good for that. I'm also looking into latest new, top ten, stuff like that.

Test 1. (Test to see if having one xml file per product is viable)

700 separate xml files in one directory. Each file is opened and searched using simplexml with an xpath expression.

The php script executes in 0-1 seconds which doesn't really tell us much, so I ran the apache ab benchmark. Here are the results:

command line: ab -n x -c y http://localhost/xmlTest.php
where x and y are some numbers

below are values for n and c that I used in the command
Expand|Select|Wrap|Line Numbers
  1. n         c                   longest request (ms)    time (seconds)
  2.  
  3. 5        1                    718                          NA
  4. 5        2                   1375                         NA
  5. 5        3                   2031                         NA
  6. 10        1                   703                        6.7 seconds
  7. 1000    1                 NA                              NA
  8.  
Test 2. (Test to see if having 700 products in one xml file is viable)

Expand|Select|Wrap|Line Numbers
  1. n       c                    longest request (ms)    time (seconds)
  2. 5       1                   218                            0.921875
  3. 5       2                  406                         1.15625
  4. 5       3                   687                         1.140625
  5. 10       1                  359                        2.21875
  6. 1000    1                 406                      194.45315
  7.  
Test 3. (Two Mysql tables with referential intergrity enforced - 735 records)

Expand|Select|Wrap|Line Numbers
  1. n       c                  longest request (ms)    time (seconds)
  2. 5       1                  15                            0.625
  3. 5       2                  31                            0.625
  4. 5       3                  31                            0.46875
  5. 10      1                  15                          0.109375
  6. 1000    1                 31                               10.9
  7. 1000    5                78                                 11
  8.  
May 28 '07 #2
dorinbogdan
839 Expert 512MB
Thanks for posting the results.

We could not do it better than you.

Dorin.
May 28 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: J P Singh | last post by:
Hi All I have been asked to build a search page to allow users to search the database. The issue is that the search page in ASP must mirror out existing search screen on the VB application. I...
4
by: JP SIngh | last post by:
Hi There I am creating a search page and need help writing the code to build the sql string. I have 3 fields on the main page which a user can choose to enter search terms in any of the 3...
19
by: James Fortune | last post by:
I have a lot of respect for David Fenton and Allen Browne, but I don't understand why people who know how to write code to completely replace a front end do not write something that will automate...
3
by: Jan Szymczuk | last post by:
I am trying to create a query that will show me who is phoning who in an organisation from available Telephone Billing information. I am creating a MSAccess 2000 database with a few few tables, two...
7
by: greywire | last post by:
So I need to load lots of data into my database. So I discover LOAD DATA INFILE. Great! This little gem loads my CSV in blazing times (compared to parsing the file and doing INSERT for each...
1
by: Eric | last post by:
Hi: I have two files. I search pattern ":" from emails text file and save email contents into a database. Another search pattern " field is blank. Please try again.", vbExclamation + vbOKOnly...
5
by: Mark | last post by:
Hi I have an application (in vb.NET 2005) which holds data in SQL Server and some of the SQL records are simply paths to related files. I would like to be able to do a text search on both the...
1
by: SqlBeginner | last post by:
I have a physical folder which contains 'n' number of documents (*.docs), excel sheets (*.xls), few PDF files (*.pdf). These files contains images within these files. Now from my website (ASP.NET...
0
by: clintonG | last post by:
Putting the search textbox on the page is the easy part. What's preferred way to find terms in XML files located on the file system? Like finding stuff saved in XML files some of the blogs use...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.