Answer the question
In order to leave comments, you need to log in
Yii2 Debug How many database requests?
I make a request in the controller:
$user = User::find(
['status' => 10],
['username' => Yii::$app->request->get('id')])
->one();
Answer the question
In order to leave comments, you need to log in
when executing a query in a model, the following happens:
1. A query to get the table structure
2. A query to get the number of table records
3. A query to get data for the specified selection To
avoid this (in production), you should use the database schema caching, for this it is enough to register the connection to the database in the config, for example:
enableSchemaCache' => true,
'schemaCacheDuration' => 180000,
'schemaCache' => 'cache'
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question