I have a Amazon RDS db.t2.large database and connect to it via laravel's forge on digital ocean. I run laravel 5.2.
I have made an artisan command which is filling database settings at every release. Forge timed out after 2 minutes. To check if it was Forge that was slow, i used putty to login in the server and manually rolled out a release. That showed me that it are the manual created artisan commands.
I have an array of +/- 200 elements that i want to insert in a database.
$arrayvalues[] = ['group' => 'groupname', 'key' => 'key_in_group', 'translation' => 'translation_of_key'];
$arrayvalues[] = ['group' => 'groupname', 'key' => 'key_in_group', 'translation' => 'translation_of_key'];
foreach($arrayvalues as $key => $value){
$findkey = MyModel::where('group', $value['group'])->where('key', $value['key'])->first();
if(isset($findkey->id) AND $findkey->id > 0){
//found, insert new translation
LanguageSystemTranslation::firstOrCreate(['language_id' => 2, 'language_system_key_id' => $findkey->id, 'value' => $value['translation'], 'user_id' => 1]);
}
else{
//ignore
}
}
There are indexes on group and key. As wel as on language_id and language_system_key_id.
The jobs are defined as "helper" in the " App > Helpers" folder.
The job alone takes 200 seconds. On my local computer it takes 1-2 seconds.
Any idea what the issue can be?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire