P
P
Petr Fronin2016-04-25 13:22:49
Yii
Petr Fronin, 2016-04-25 13:22:49

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();

Debug issues DB 3 20ms
If I understand correctly, this means 3 queries to the database in 20ms Why???
Or Yii2 in some tricky way fulfills this request 3?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Fedorov, 2016-04-25
@amar_std

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 question

Ask a Question

731 491 924 answers to any question