Simpel call very slow (too many relations?)

I am building my first yii2 app and I am really enjoying it.

Now I created a new table (25 columns with text fields)

that has 2 foreign keys

Another table links to this primary table, and this second table has 5 foreign keys

There 2 rows in every table

Now after creating the models, crud with GII

the primary table does show the information, however it takes a whopping 30+ seconds to do so.

What am I overlooking?

Are there too many relations ?

Maybe too many colums with plain text ?

Post the code, so it seems all right.

Where is the query the require 30+ seconds to be executed?

How can you be sure that time is taken from the query?

I just used the plain gii code, no edits

I know when I used the same procedure (just gii) for another table. that loaded fine, this ‘emap’ index page takes 30 seconds (I am counting the seconds manually on my watch)

If you are calling ‘index’ action, I’ll put a var_dump immediatety after the data provider initialization and getModel() call.

    public function actionIndex()


        $searchModel = new EmapSearch();

        $dataProvider = $searchModel->search(Yii::$app->request->queryParams);

        // This call is needed to load all data provider data

        $item = $dataProvider->getModels();

        var_dump('all items loaded');  

        exit;   // action stops here

        return $this->render('index', [

            'searchModel' => $searchModel,

            'dataProvider' => $dataProvider,



One thing I would suspect is that you are missing some indexes on your table…


That suggestion peeked my interest. Although it was not a index problem, but another problem related to an event handler that was called many many times

Thanks guys !!!