Follow us on...
Follow us on Twitter Follow us on Facebook
Register

User Tag List

Page 1 of 2 12 LastLast
Results 1 to 10 of 13
  1. #1
    Message me for help! :D Gabby's Avatar
    Join Date
    01 Apr 2012
    Location
    With the zeros and ones in New York
    Posts
    4,442
    Threads
    249
    Blog Entries
    5

    My Social Networking


    Visit Gabby's Vimeo Channel

    My User Ranks

    My Reputation

    Too many MySQL tables?

    I was reading about databases with a ton of tables on Stack Overflow and I found that some people feel there is a performance impact when there is too many MySQL tables on a server. But in the same breath, it caused a huge debate with people who disagree. I'm just wondering if there's a proven answer? Maybe with trials or something?

    I know database normalization may result in many tables, which has me so confused. Of course, I know, normalizing all of your data helps the health of your database in the long run, but it also creates more MySQL tables, which some say cause a performance impact, so does anyone have a straight answer to this? XD

    __________________________________________________

    Maynard: I think most of us grew up in a pretty sterile environment. A
    lot of that stuff just wasn't around. It's all pretty much peaches and
    cream . . . flowers . . . everything's nice, ignore all the bad stuff.
    And the world's just not like that. And I think that the sooner people
    get to the point where they realize that the ugly stuff is just as
    important as the beautiful stuff - it goes hand in hand, I think that
    we can get on with evolving.
    -
    The Tool Page: Articles


  2. #2
    Approved Game Owner Chevy's Avatar
    Join Date
    25 Mar 2011
    Posts
    151
    Threads
    25

    My User Ranks



    My Reputation

    Re: Too many MySQL tables?

    I would say make as few tables as you need, but with a pet site, it will be quite a few. Once you start putting rows in the wrong table (places that don't make sense) or make a table for site wide global fields (which I think is totally unnecessary, some might differ in that opinion) it gets really confusing.

  3. #3
    Approved Programmer
    Join Date
    23 Jan 2011
    Posts
    824
    Threads
    40
    Blog Entries
    2

    My User Ranks




    My Reputation

    Re: Too many MySQL tables?

    The alternative is to have VARCHAR (text-based) lookups on your main tables (instead of INT lookups). The VARCHAR lookups will be way more expensive on a big fact table than any impact of too many tables in a MySQL database. People choose very interesting things to have holy wars over. This being one of them. I'm guessing that the people who are throwing out the facts about how too many tables will cause a performance hit are the same people who say all normalization is bad. Probably sponsored by the "anti-join order".

    The fact is, if you are storing the VARCHAR version of the text on each table, you will be duplicating a lot of information (the string value) which costs more (disk space wise, and index wise) than storing an integer value. Example:
    VARCHAR(50) => if full will take 51 bytes worth of disk/index space (per row) - actual size of VARCHAR fields is the length of content in the row + 1 byte (i.e. 4 characters long = 5 bytes)
    CHAR(50) => will take 50 bytes worth of disk/index space (per row)
    INT => 4 bytes worth of disk/index space (per row)

    Yes, you acquire a little more overhead from having to do a table lookup against your dimension table, but at the end of the day, you are saving a lot of disk/index space using an INT. Smaller column width means that more of the index can fit on any given page. More indexes per page means quicker querying times.

    Also, string comparisons actually take a fair bit more time to actually execute than the INT comparisons (it needs to pull all of the bytes into memory and scan one-by-one).

    In short, normalize your tables it'll make your life easier, cleaner, and keep your database as small as it can be.

    ~judda
    Last edited by judda; 03-04-2013 at 10:25 AM.
    Personal Site, Blog, Development Projects all wrapped up into one convenient location. Click here to begin. I am very straight to the point ... if you don't like it ...just feel free to ignore me.

    Blog :: Development Blog :: Resume




    Virtual Pet News - Aggregator of all pet site News Feeds
    SQL Blog Feed - Aggregator of several SQL blog sites
    PHP Blog Feed - Aggregator of several PHP blog sites

  4. #4
    VPL Supporter Hituro's Avatar
    Join Date
    01 Feb 2011
    Posts
    1,293
    Threads
    220

    My User Ranks


    My Reputation

    Re: Too many MySQL tables?

    When a database is opened there is overhead that relates to the number of tables, and also the size of the tables, especially with InnoDB, where you are storing all of the tables in one file. But I think that's more to do with total DB size than number of tables. I don't think there is a big downside to lots of small tables, and I think like @judda says, it's better to have more small specialised tables than big generic ones with string keys.

    For reference Grophland currently has 95 tables

  5. #5
    Moderator Mio's Avatar
    Join Date
    04 Oct 2012
    Location
    Greenville, NC
    Posts
    646
    Threads
    30
    Blog Entries
    8

    My Social Networking


    Follow Mio on Tumblr Visit Mio's Vimeo Channel

    My User Ranks






    My Reputation

    Re: Too many MySQL tables?

    Quote Originally Posted by judda View Post
    People choose very interesting things to have holy wars over. This being one of them. I'm guessing that the people who are throwing out the facts about how too many tables will cause a performance hit are the same people who say all normalization is bad. Probably sponsored by the "anti-join order".
    LOL anti-join order.

    In short, normalize your tables it'll make your life easier, cleaner, and keep your database as small as it can be.
    Seconded. The cleanliness has it for me.
    Last edited by judda; 03-04-2013 at 10:56 AM. Reason: Fixing a typo in my post :P

  6. #6
    Approved Game Owner
    Join Date
    28 Feb 2011
    Location
    California
    Posts
    447
    Threads
    37

    My Social Networking

    Add Myztacia on Facebook

    My User Ranks


    My Reputation

    Re: Too many MySQL tables?

    I agree with @judda on this as well. However, I still say do this within reason. :]

  7. #7
    Message me for help! :D Gabby's Avatar
    Join Date
    01 Apr 2012
    Location
    With the zeros and ones in New York
    Posts
    4,442
    Threads
    249
    Blog Entries
    5

    My Social Networking


    Visit Gabby's Vimeo Channel

    My User Ranks

    My Reputation

    Re: Too many MySQL tables?

    Quote Originally Posted by Myztacia View Post
    I agree with @judda on this as well. However, I still say do this within reason. :]
    Oh of course, I do everything with moderation (unless you're talking about cheese... or ice cream.. aaaah XD)

    __________________________________________________

    Maynard: I think most of us grew up in a pretty sterile environment. A
    lot of that stuff just wasn't around. It's all pretty much peaches and
    cream . . . flowers . . . everything's nice, ignore all the bad stuff.
    And the world's just not like that. And I think that the sooner people
    get to the point where they realize that the ugly stuff is just as
    important as the beautiful stuff - it goes hand in hand, I think that
    we can get on with evolving.
    -
    The Tool Page: Articles


  8. #8
    VPL Supporter
    Join Date
    09 May 2011
    Posts
    908
    Threads
    102

    My User Ranks

    My Reputation

    Re: Too many MySQL tables?

    I have about 20 tables and each table is specific per area or feature. The only table thats big, width wise is the pet table since there's a lot of info per pet, but some of the game tables are ever growing in length but have few columns.

  9. #9
    Message me for help! :D Gabby's Avatar
    Join Date
    01 Apr 2012
    Location
    With the zeros and ones in New York
    Posts
    4,442
    Threads
    249
    Blog Entries
    5

    My Social Networking


    Visit Gabby's Vimeo Channel

    My User Ranks

    My Reputation

    Re: Too many MySQL tables?

    Quote Originally Posted by BigThinker View Post
    I have about 20 tables and each table is specific per area or feature. The only table thats big, width wise is the pet table since there's a lot of info per pet, but some of the game tables are ever growing in length but have few columns.
    I would personally have two tables. One for all the species information and one for all the necessary data that needs to be saved per pet. I don't know if you combined the two but I'd be careful if you did. A simple INNER JOIN query would be able to join the two tables together if you needed any information from both. A lot of columns could impact performance, it's harder to manage, and it isn't really good normalization practice.

    @judda correct me if I'm wrong. ^.^

    __________________________________________________

    Maynard: I think most of us grew up in a pretty sterile environment. A
    lot of that stuff just wasn't around. It's all pretty much peaches and
    cream . . . flowers . . . everything's nice, ignore all the bad stuff.
    And the world's just not like that. And I think that the sooner people
    get to the point where they realize that the ugly stuff is just as
    important as the beautiful stuff - it goes hand in hand, I think that
    we can get on with evolving.
    -
    The Tool Page: Articles


  10. #10
    Approved Game Owner
    Join Date
    28 Feb 2011
    Location
    California
    Posts
    447
    Threads
    37

    My Social Networking

    Add Myztacia on Facebook

    My User Ranks


    My Reputation

    Re: Too many MySQL tables?

    @Gabby That's me with Reese's, ice cream, and avocados! :]
    @BigThinker The number of columns isn't necessarily a problem. If you're creating a table just because you want to remove some of the columns from another, that probably isn't the way to go. (I'm not saying you are! I just felt it worth mentioning for future readers of the post.) Keeping them grouped in ways that make sense, such as grouping by area, is definitely a great start. As a programmer becomes more familiar with databases and grouping data, it will be easier to see where one can save on performance by breaking up tables.

    Along these lines, it's more important to get the correct datatype rather than worry about how many fields there are. If you have 10 very useful fields but they're all in the wrong datatype, you'll suffer performance later on. In particular, as @judda said, indexes should be in the most efficient way they can be.

    One final point I would like to make is that if it is becoming hard to understand where to find data in your database, you are probably breaking the tables down too much. It will be harder for yourself and future programmers to maintain the code.

 

 

Similar Threads

  1. Offering Programming php/mySQL/js/jQuery Programming
    By Sim in forum Programming Marketplace
    Replies: 12
    Last Post: 10-22-2012, 03:43 PM
  2. Offering Programming Looking for PHP/MySQL work
    By Chevy in forum Programming Marketplace
    Replies: 2
    Last Post: 09-08-2012, 03:45 PM
  3. NEED a PHP/MySql tutor for petsite!
    By Sno in forum Services
    Replies: 5
    Last Post: 04-03-2012, 12:29 AM
  4. [For Hire] PHP/MySQL Developer
    By JohnMaguire2013 in forum Programming Marketplace
    Replies: 4
    Last Post: 02-29-2012, 02:49 PM
  5. MySQL Server Overall Tips by mysql.com
    By cpvr in forum Programming General
    Replies: 0
    Last Post: 03-23-2011, 03:32 PM

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
  •