mercredi 22 juin 2016

How can I get count number of connection for multiple queries?

Sometime I access my page and get error from Mysql:

Too many connections

I fixed it by change max_connections in mysql config.

But I'm not sure for each request, how many connection be opened.

For example, my request call the function index:

public function index($id) {
   $user = DB::table('users')->find($id);
   $post = DB::table('posts')->where('user_id', $user->id)->first();
   $post->author = 'created by ' . $user->name;
   $post->save();
}

That function just find a user, then rename author column of first user's post.

That seem like 3 queries be executed, so how many connection be opened? 3 or 1?

How can I check the number of connection exactly? something like: return number_mysql_connection;



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire