SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast Jujubee's Avatar
    Join Date
    Mar 2001
    Location
    Canada
    Posts
    98
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    What's faster - db access or file access?

    I'm trying to speed up my PHP scripts as much as possible.

    This is for header/footers for my pages, so it's read-only access; no writing.

    What's faster?

    1) importing via require()
    2) reading from the MySQL db


    Also, would the situation change if writing were required? I'm pretty sure writing to a DB is faster than writing to a file...

    Thanks!

  2. #2
    SitePoint Zealot theFinn's Avatar
    Join Date
    Oct 2000
    Location
    Edmonton
    Posts
    102
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'd wager that the require() is faster because you don't have the overhead of the MySQL connection.

    If writing was required it might make a difference if it was a complex write. If you were just taking something onto the end of the file the filesystem would probably still be faster. If you wanted to stick something in the middle then the DB would be much better
    - theFinn
    Creator and Project Manager, phpBB
    http://www.theFinn.net
    http://www.tarotclass.com

  3. #3
    SitePoint Member Albertstine's Avatar
    Join Date
    Nov 2001
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have just finished reading something about persistant database connections in php. This is when a child process connects to the database just once and keeps the connection open, this could be interesting to read and to consider.

    Persistant database connections are dependant on what web server you have installed and how it was installed.

    Take a look at chapter 22 page 156 of the php manual.



    Hope this helps.

  4. #4
    SitePoint Enthusiast Jujubee's Avatar
    Join Date
    Mar 2001
    Location
    Canada
    Posts
    98
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think persistant connections applies across all scripts during a users session.

    I'm wondering about db access vs file system access.

  5. #5
    SitePoint Enthusiast Jujubee's Avatar
    Join Date
    Mar 2001
    Location
    Canada
    Posts
    98
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Anybody else have any opinion on this subject?

    require() vs. pulling from DB ?
    Last edited by Jujubee; Nov 6, 2001 at 00:55.


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
  •