dimanche 30 décembre 2018

How to reduce loading time of sql query?

I had created a query to get a list of staffs using this query:

  $itemregistrations = DB::table('itemregistrations')
                       ->join('sections', 'itemregistrations.sectionid', '=', 'sections.sectionid')
                       ->join('categories', 'itemregistrations.categoryid', '=', 'categories.categoryid')
                       ->join('operasi', 'itemregistrations.operasiid', '=', 'operasi.operasiid')
                       ->select('itemregistrations.ItemRegistrationID','itemregistrations.name', 'itemregistrations.Nobadan', 'sections.sectionname', 'categories.categoryname', 'operasi.operasiname')
                       ->get();

However, the query gets loading quite long, about a minute to finish loading. The list displayed about 1256.

How to reduce the loading time?

I read about eager loading to decrease the loading time. But my trial not success.

section is the department of staffs.

categories is the staff level

operasi is the grade of staff, related to categories, each category has its own operasiname.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire