SitePoint Sponsor

User Tag List

Results 1 to 11 of 11

Thread: XML and DB Size

  1. #1
    SitePoint Zealot
    Join Date
    Mar 2008
    Posts
    183
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    XML and DB Size

    Hey all, just a question probably not asked too much.

    On my site i write certain information to an XML file and other info to a DB.

    Just looking into the future, are there any possible problems i could run into in terms of file size? Put aside disk space, im talking in terms of speed and anything else.

    For instance, if my XML file eventually reaches 100Mb, how much will this affect the speed of my PHP script which grabs data from the XML file?

    Anyway, any input into this topic would be greatly appreciated

    Thanks in advance, Nick
    Win A FREE iPhone!

    Tired from working? Funny Things! Laugh the stress away
    Some Funny Jokes | Funny Videos

  2. #2
    SitePoint Enthusiast zombat's Avatar
    Join Date
    Jun 2008
    Location
    Victoria, BC
    Posts
    63
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Nick,

    That's a bit of a subjective question, as it really depends on what you're doing with the data. If you're parsing the XML file each time your script runs, or creating a DOM structure out of it in your PHP code, then you might run into some pretty serious resource crunches when you have to keep reading the file into memory. If you're just tacking log entries onto the end of it, or anything like that, it might not be so bad.

    Can you post a little bit more about what you use the XML file for?
    PHP/MySQL programmer for hire!
    http://www.zombat.net

  3. #3
    SitePoint Zealot loathsome's Avatar
    Join Date
    Jul 2008
    Location
    Norway
    Posts
    121
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What zombat points out is very important and true. Whenever you're going to read data from a flat file, you need to load it in to memory first -- with a real database like ORACLE/MySQL, you can fetch only the queries you want, ergo, saving a lot of resources.

    Anyway, to fully answer your question, you need to broaden your question a bit and tell us exactly what you use the XML database for.
    Time you enjoy wasting is not wasted time.

    Loathsome Systems

  4. #4
    SitePoint Zealot
    Join Date
    Mar 2008
    Posts
    183
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Haha ok ok kool Ill give you the big picture.

    User posts (very similar to a forum).

    Information about the post is entered into a DB and the content of the post is appeneded to the XML file (each post has its own id in the XML file).

    Then when some1 wishes to view the post, data about the post is grabbed from the DB and then using XPath (just searching for the ID) that post is "grabbed" from the XML file.

    Comments are also appended to the corresponding post in the XML file.

    Need any more info?

    Also i've been thinking about security things lately, is there someway i can restrict access to this xml file?

    Thanks heaps, Nick
    Win A FREE iPhone!

    Tired from working? Funny Things! Laugh the stress away
    Some Funny Jokes | Funny Videos

  5. #5
    SitePoint Zealot loathsome's Avatar
    Join Date
    Jul 2008
    Location
    Norway
    Posts
    121
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Wait, what? Are you storing both posts and comments in only one XML-file? That is really not what XML is meant for at all. If that's the case, I really encourage you to take a look at some real databases. Why reinvent the wheel? What method are you using to manipulate the XML file? SimpleXML, DOM, etc.

    Quote Originally Posted by NickPaul View Post
    Also i've been thinking about security things lately, is there someway i can restrict access to this xml file?
    There's multiple ways to do this. You could for example store the file outside your accessible folder (commonly called "public_html"), or in it's own folder (eg named "database/"), then just put a .htaccess file with deny from all in it. This will prevent anyone from accessing the file, thus PHP can still access and modify it.
    Time you enjoy wasting is not wasted time.

    Loathsome Systems

  6. #6
    SitePoint Zealot
    Join Date
    Mar 2008
    Posts
    183
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Simple XML lol where should i be storing the posts? Should i just change it so comments and posts are in seperate xml files, or do i need a complete overhaul lol i coded this up from scratch, i just do this stuff in my spare time as a hobby.

    Any advice would be great lol some hard work now will be better than the possible disaster awaiting me haha

    Thanks in advance, Nick
    Win A FREE iPhone!

    Tired from working? Funny Things! Laugh the stress away
    Some Funny Jokes | Funny Videos

  7. #7
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I would recomend a database instead of xml for this. It's more suitable. It can be orders of magnitudes faster, easier to manipulate data, more robust.

  8. #8
    SitePoint Zealot loathsome's Avatar
    Join Date
    Jul 2008
    Location
    Norway
    Posts
    121
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I second what crmalibu are saying. Definitely go for a real database, even though it's for learning purposes only :-)
    Time you enjoy wasting is not wasted time.

    Loathsome Systems

  9. #9
    SitePoint Zealot
    Join Date
    Mar 2008
    Posts
    183
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Haha im sorry, i dont understand what you mean by a 'real' database.

    So for example, is the post content from these forums stored in a DB, not an XML file?

    And what would i set the field size to? Unlimited or just a rediculously high number??

    Haha any help with that last question would be great, once i know that ill go with just DB lol no XML (in one of my book on Java i saw an example where they used XML to create a forum lol i thought it must've been the right way, damn!).

    Thanks in advance, Nick
    Win A FREE iPhone!

    Tired from working? Funny Things! Laugh the stress away
    Some Funny Jokes | Funny Videos

  10. #10
    SitePoint Zealot loathsome's Avatar
    Join Date
    Jul 2008
    Location
    Norway
    Posts
    121
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    MySQL or PostgreSQL would be a good starter
    Time you enjoy wasting is not wasted time.

    Loathsome Systems

  11. #11
    SitePoint Zealot
    Join Date
    Mar 2008
    Posts
    183
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Haha im using MySQL, most of my system is run through MySql, i just choose to store the post content (like the stuff i'm writting here) in an XML file. Should i add a field in my post information table to store the post content also? And what would i set the field size to? postContent VARCHAR(??).

    Thanks heaps, Nick
    Win A FREE iPhone!

    Tired from working? Funny Things! Laugh the stress away
    Some Funny Jokes | Funny Videos


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •