Witam.
Mam prośbę o wytłumaczenie mi jak czytać logi zapytań do bazy danych.
Mam taki kod zapytania:
DB::connection()->enableQueryLog();
$post = Post::with(['poll','comments'])
->where(['id' => $id])
->withTrashed()
->firstOrFail();
print_r(DB::getQueryLog());
Jako rezultat otrzymuję :
Array ( [0] => Array ( [query] => select * from `posts` where (`id` = ?) limit 1 [bindings] => Array ( [0] => 1 ) [time] => 1.86 ) [1] => Array ( [query] => select * from `polls` where `polls`.`post_id` in (?) [bindings] => Array ( [0] => 1 ) [time] => 0.17 ) [2] => Array ( [query] => select * from `comments` where `comments`.`post_id` in (?) [bindings] => Array ( [0] => 1 ) [time] => 0.58 ) )
Czyli jak mam to rozumieć? Skrypt odpytuje bazę danych 3 razy? Czy może zapytanie jest jedno z zagnieżdżonymi selectami?
I czy to jest optymalne zapytanie?
Dziękuję