Results 1 to 7 of 7

 

Thread: mySQL - which is faster - 4 large tables in one database or a database for each?

  1. #1
    Registered User

    Status
    Offline
    Join Date
    Aug 2003
    Posts
    401
    Thanks
    3
    Thanked 7 Times in 7 Posts


    Heya,

    Just wondering before I embark on a new project...

    Say I want to have several large tables for *fairly* independent sites - all between 200-600mb, all hosted on the same server

    Would it be quicker to slap all the tbales in one database or to create an independent database for each one? I'll be doing fulltext searches and the like so load wil get quite high..

  2. #2
    Registered User

    Status
    Offline
    Join Date
    Jan 2007
    Location
    Channel Islands
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It shouldn't make a lot of difference. Server load would be the same. It would be worth asking your host what the server load is over 5, 10, 15 and 20 minutes.

    I would use separate dbases. Its no more difficult and allows more portability.

  3. #3
    Registered User

    Status
    Offline
    Join Date
    Aug 2006
    Location
    Hadleigh, Suffolk, UK
    Posts
    954
    Thanks
    0
    Thanked 0 Times in 0 Posts
    makes no difference. Just means the table files will be stored in a different directory that's all. It'll be just as fast either way.

  4. #4
    Registered User

    Status
    Offline
    Join Date
    Aug 2005
    Posts
    128
    Thanks
    0
    Thanked 1 Time in 1 Post
    I'd imagine a slight improvement by splitting it - consider if you had 4 incoming queries at the same time, the much larger table and associated indexes would yield a slightly longer time to resolve each and every query, than the same 4 queries against 4 smaller tables and indexes as they have much less info to wade through.

    Also it makes each site independantly redundant from each other - if that large table corrupts for any reason all sites go bang together.
    haggul

  5. #5
    data muncher

    Status
    Offline
    Join Date
    Sep 2004
    Location
    Berlin
    Posts
    2,475
    Thanks
    0
    Thanked 0 Times in 0 Posts
    4 seperate tables would be faster generally and a lot less load on the machine, four seperate databases would actually do the same. Its nice to have everything in one table but then you would probably have to make extra queries to isolate the 4 different bits of info

    like SELECT FROM table_name WHERE category = xxxxx

    whereas if you put the category of information into one table then it would be

    select from table_name

    I am not so much of a database techy but i think off the top of my head on one machine when we took the database table up to about 3gb we had serious problems with the machine coping with running http server at the same time during busy periods. When we split the table into two seperate tables it was fine to run two tables both at 2.5gb.
    Nothing to see here...

  6. #6
    Registered User

    Status
    Offline
    Join Date
    Aug 2003
    Posts
    2,448
    Thanks
    0
    Thanked 0 Times in 0 Posts
    As others have said there should be much difference between one database with 4 tables and 4 databases with one table each as most things work at a table level. I guess one database may be fractionally quicker, but not in any visible way.

    If the sites are going to share any data in other tables then I would definitely keep them together.

  7. #7
    Registered User

    Status
    Offline
    Join Date
    Aug 2006
    Location
    Hadleigh, Suffolk, UK
    Posts
    954
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Just incase there was confusion, here's how mysql would store the data on the file system...

    /var/lib/mysql/DATABASE1/TABLE1.MYD
    /var/lib/mysql/DATABASE1/TABLE2.MYD
    /var/lib/mysql/DATABASE1/TABLE3.MYD
    /var/lib/mysql/DATABASE1/TABLE4.MYD

    vs

    /var/lib/mysql/DATABASE1/TABLE1.MYD
    /var/lib/mysql/DATABASE2/TABLE2.MYD
    /var/lib/mysql/DATABASE3/TABLE3.MYD
    /var/lib/mysql/DATABASE4/TABLE4.MYD

    So it really won't make a blind bit of difference in terms of speed. It'll just make your SQL a bit longer with the 2nd one if you need to cross reference the tables, as you'll have to specify the database as well as the table in the SQL.



Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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
  •  
To Top

Content Relevant URLs by vBSEO 3.5.0 RC2