1

Actually i need to increase the performance speed in my web application developed by using Yii 2 .0 Framework

I have made a CRM using Yii2 Framework, That contains a large database, in that database particular table called Employee contains 20,000 employee records, so while executing query to retrieve data from table, it takes time to execute.

This makes it troublesome for me to use this application.

UPDATED code:

public function actionLists($id)
    {
         $countClaimprocess = Employee::find()
            ->where(['id' => $id])
            ->count();

    $claimprocess1 = Employee::find()
            ->select('employee_id')
            ->where(['id' => $id])
            ->one();

    $claimprocess2 = Employee::find()
            ->select('importcompany_id')
            ->where(['id' => $id])
            ->one();

    $claim2 = $claimprocess2->importcompany_id;

    $claim = $claimprocess1->employee_id;

    $claimprocess = Employee::find()
            ->where("employee_id = '$claim'  and importcompany_id = $claim2")
            ->andwhere(" status != 'Deleted' ")
            ->all();

    }

The above code is used for a dependent dropdown, that means if a admin select a company_name, it will show a dependent employee_code belonging to that company, and then again admin selects a employee_code, it will show the dependent employee_name and their family members name.

tarleb
  • 19,863
  • 4
  • 51
  • 80
Nodemon
  • 1,036
  • 2
  • 25
  • 47

1 Answers1

0

Start from logging your queries (described here).

When you already have this query in SQL format go to your database management application (e.g. phpmyadmin) and execute EXPLAIN [query_body]; It will show you if your table has proper indexes. If no indexes are used or you don't have any you should fix it by adding one or writing more accurate query. I bet it's not yii2 specific problem or even php but your db system.

Columns that should be indexed in employee table are: employee_id, importcompany_id and status

Also think about changing status column to some enumerated integer value (it's hard to properly index strings due to it's size).

Community
  • 1
  • 1
Glapa
  • 790
  • 10
  • 20