MYSQL + PHP

eedioteediot Join Date: 2003-02-24 Member: 13903Members
I'm not too familiar with the limitations of Mysql. I've got it installed via xampp on my system, and am about to use a php for loop to create and populate a table with 9801 entries. Before I write the code and execute it, I want to check that this isn't a ridiculous idea akin to splitting a 700mb file into several million segments within a window folder. How many values can a mysql table hold on a gaming machine before it becomes inefficient?

Comments

  • RobRob Unknown Enemy Join Date: 2002-01-24 Member: 25Members, NS1 Playtester
    Well, in the extreme, it depends on how big a single table row is. Since I'm doubtful your rows are several megs a piece, space shouldn't be an issue. If you plan on using your gaming rig as a development box (ie, you only turn on the mysql server when you're working on stuff) then you're perfectly fine.

    If you want to serve the mysql all the time, though, you'll be taking a performance hit on your other applications, depending on how busy the mysql server is. I'd recommend just buying some shared hosting in this case. I use Dreamhost, and I'm pretty happy with them.

    As for using PHP to populate the server, it might be better to just write an .sql file with INSERT statements, unless you need the php code to go out and get data to be put into the server or something.
  • eedioteediot Join Date: 2003-02-24 Member: 13903Members
    edited September 2015
  • DOOManiacDOOManiac Worst. Critic. Ever. Join Date: 2002-04-17 Member: 462Members, NS1 Playtester
    edited September 2008
    You don't have to worry about it.

    Our development box at work is something like a 1.2ghz single-core celeron and it's very speedy w/ tables that are around a gig.

    If you have 10,000 rows and things slow down, the problem won't be the hardware. :P


    Also a general tip regarding data checking:
    MySQL can almost always do it faster than PHP.
    So if you're going to turn 3 phone number fields into 1 combied field w/ dashes between them, this is something to do on the MySQL side.
  • lolfighterlolfighter Snark, Dire Join Date: 2003-04-20 Member: 15693Members
    I tell you, Cisco Callmanager or whatever it's called has a stupid, STUPID DB setup. All in a single table, 40 columns, several of them with redundant information. Now imagine 1.5 MILLION rows of this. GUH.
  • eedioteediot Join Date: 2003-02-24 Member: 13903Members
    edited September 2015
  • DOOManiacDOOManiac Worst. Critic. Ever. Join Date: 2002-04-17 Member: 462Members, NS1 Playtester
    edited October 2008
    If I'm understanding you right, what you really need is a log of activity for each player, correct?

    For this you want to create a seperate table that has these fields:
    - messageid (primary key, autoincrementing)
    - userid (foreign key)
    - message (text to store the message)
    - messagetimestamp (stores when the message was created)

    You'll insert rows into this table whenever a message happens, then when you need to display them just get the last 5. Then you just loop through the array..

    <!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->$sSQL = "SELECT message FROM messages WHERE userid = '1' ORDER BY messagetimestamp DESC LIMIT 5";
    $r = mysql_query($sSQL, $db);
    if ($r && mysql_num_rows($r))
    {
         while($row = mysql_fetch_assoc($r))
         {
              $aMessages[] = $row['message'];
         }
    }
    else if ($r && mysql_num_rows($r) === 0)
    {
         // No results returned from database, so do something else here
    }
    else
    {
         echo 'Error: '.mysql_error($r);
    }<!--c2--></div><!--ec2-->

    or something similar.


    Having 1 text field w/ up to 5 messages stored inside of it, separated by a delimiter, is about the worst thing you could do in this situation.
  • eedioteediot Join Date: 2003-02-24 Member: 13903Members
    edited September 2015
  • eedioteediot Join Date: 2003-02-24 Member: 13903Members
    edited September 2015
  • ZaggyZaggy NullPointerException The Netherlands Join Date: 2003-12-10 Member: 24214Forum Moderators, NS2 Playtester, Reinforced - Onos, Subnautica Playtester
    edited October 2008
    Ahh the joys of code without (useful) comment.

    <!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->if ($planetinfo['owner'] == $_SESSION['user']) {
    // Separate functions I guess bro
    }<!--c2--></div><!--ec2-->

    my guess:
    <!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->if owner of planet is same as currently logged in user{
    do something
    }<!--c2--></div><!--ec2-->
  • eedioteediot Join Date: 2003-02-24 Member: 13903Members
    edited September 2015
  • DOOManiacDOOManiac Worst. Critic. Ever. Join Date: 2002-04-17 Member: 462Members, NS1 Playtester
    Heh.

    Whenever I do stuff like that I always put // TODO: whatever in the code. :P

    My desk at work is also littered w/ post-its from various things.
  • KungFuDiscoMonkeyKungFuDiscoMonkey Creator of ns_altair 日本福岡県 Join Date: 2003-03-15 Member: 14555Members, NS1 Playtester, Reinforced - Onos
    edited October 2008
    <!--quoteo(post=1691106:date=Oct 22 2008, 02:56 PM:name=DOOManiac)--><div class='quotetop'>QUOTE(DOOManiac @ Oct 22 2008, 02:56 PM) <a href="index.php?act=findpost&pid=1691106"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->Heh.

    Whenever I do stuff like that I always put // TODO: whatever in the code. <img src="style_emoticons/<#EMO_DIR#>/tounge.gif" style="vertical-align:middle" emoid=":p" border="0" alt="tounge.gif" />

    My desk at work is also littered w/ post-its from various things.<!--QuoteEnd--></div><!--QuoteEEnd-->
    I usually use @todo inside of a longer /** */ comment so that both our documentation generator and my IDE pick them up and give me a nice list.

    On an unrelated note, when I'm working with some of my php scripts I have gotten php to where it uses around 500 mb of ram ;p.
Sign In or Register to comment.