dimanche 12 janvier 2020

Laravel - how the database connections are handled

I have a Laravel Application which users different databases in the same application. May be one single page might pull from two or three dbs. To handle this, I have added connections in config/database.php and i am using those connections in my model file to access different dbs. For now all dbs are using the same user to access the tables. But later it can use different users.

But now I am thinking about performance issues. When we are using these different connections, will all the connections be opened at the same time by laravel? How does laravel do this database connections? Will all the mysql connections be kept open if you are switching from using default connection to another connection using model and then back to default mysql connection.

Is there any way that I can use different db's with default mysql connection using Model?

My application's performance is now our primary concern and do you think keeping different dbs connections can slow it down?

In my connection settings, if I just change the db name and keep the same user and password, will it re-use the default database connection?

Any input on this, is much appreciated. I couldn't find any info on how laravel's internal things work.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire