What size of a large sizeable query?

Asked

Viewed 268 times

6

What size of a query considerable great? For, I need to make a function to send query for the server but I cannot exceed the limit not to crash the server:

public function sqlExecute($sql_code) {
    if ($sql_code != "" && strlen($sql_code) < 1e6) { // O TAMANHO DA QUERY AQUI
        echo '1';
    }
    else {
        echo '2';
    }
}
  • SSH, I can’t pass the memory and I can’t pass the time.

1 answer

9


In Mysql you can check this with:

SHOW VARIABLES WHERE Variable_name = "max_allowed_packet";

I put in the Github for future reference.

This same variable can be changed in the my.ini or my.cnf. It can be up to 1GB but is likely to be configured by default with 1MB.

That is, you don’t have much to worry about in most cases except changing the value of this variable if necessary, which will rarely be. If a very large size is required, one must consider whether that solution is ideal.

You can run out of PHP running time if a query is too big.

  • Thank you very much! And to set a runtime? For example: if the query takes 1 minute to run, stop .

  • 1

    This is another question, but I general there is time limit from the point of view of Mysql. You may have other limits, this usually occurs in PHP and is running as script for web this time is usually relatively low. But overall enough for almost all darlings. If not enough, strategies need to be adopted to deal with this, but as I said, this is another matter.

  • 1

    To increase the time limit of the request in php you can use the function set_time_limit pass zero as argument so no time limit will be imposed. @misakie

  • @rray is also worth seeing here http://php.net/manual/en/info.configuration.php#ini.max-Execution-time.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.