Mysql limits

I recently got suspended for going over mysql usage. I want to know why, as I just made a test connection to my mysql server to make sure everything works the way I want it to. I would love if someone told me why it went over the usage limits when ( I believe) I used so little usage. Here’s the code:

<?php
//Replaced the login credentials because I don't want them publicaly visible
$servername = "server";
$username = "Username";
$password = "Password";

try {
  $conn = new PDO("mysql:host=$servername;dbname=epiz_25232296_feedback", $username, $password);
  // set the PDO error mode to exception
  $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  echo "Connected successfully";
} catch(PDOException $e) {
  echo "Connection failed: " . $e->getMessage();
}
try{
    $sh = $conn->prepare( "DESCRIBE `test`");
    if ( $sh->execute() ) {
        // my_table exists
    }
    else {
        // my_table does not exist
        $sql = "CREATE TABLE test (
        id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
        test CHAR
        )";
        // use exec() because no results are returned
        $conn->exec($sql);
        echo "Table created successfully";
    }
} catch(PDOException $e) {
  echo $sql . "<br>" . $e->getMessage();
}
try{
    $sql = "INSERT INTO test (test)
  VALUES ('J')";
  // use exec() because no results are returned
  $conn->exec($sql);
  echo "New record created successfully";
} catch(PDOException $e) {
  echo $sql . "<br>" . $e->getMessage();
}
$conn = null;
?>

Have you already read this one?

yes I have. I want to know if what I was doing used up the server’s load because in my opinion, I used very little usage.

Every time you refresh the page, tweak some code or just open the tab, it may reload and refresh, so everytime you would check if it works, you send a query and each query, counts as some mysql, or if your code wasn’t optimized, it may not be efficiently transferring data

I guess because if you’ve run the php code, it will also create an another table, so that might be the reason of sql overloading.

There’s my answer, yes. But I only did this about 20 times. If 20 people or more were to visit my website, it would be suspended. This seems like a very low usage then.

Well, rather than say query the database, as @katufo says, everytime you reload you create a new table, which needs more storage, wheras when only querying the server with (What is in this table?) you are creating a table.

I can’t really explain

Plus you might just have been the only one creating a table and the system spotted you

You can’t actually create another table with the same name otherwise it gives you an error. I put in some code that checks if the table exists. I’m only putting in one thing into the table. I want to categorize about 150 items with mysql, and I am worried this would be way too much for the “free unlimited hosting” plan. I don’t want to buy premium just yet

Ok, well would it be possible to use PHPMYADMIN, as that does not use up as many Mysql usage (i think)?

I guess that would work, but I want to also have an admin page where you can add categories for a new item (which would create a new table). If I visit the page 20 times, and make about 60 queries total (On average I made 3), I am worried what would happen if only a handful of people visit my website that queries about 60 items from the table.

Like i say, querying uses up a lot less of everything, as you just have to;

Locate Server => Authenticate => Find Database => Show Info

But with writing you have to

Locate Server => Authenticate => Find Database => Locate Where to insert => Open Channel => Send Data => Recieve Data => Encrypt Data => Return Message/Error

Basically querying only is fine, but like i say, you might just have been unlucky to be the only one, My support can only stretch this far.

2 Likes

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.