简体   繁体   中英

How to Optimize CodeIgniter Query Performance?

In one of my client project, I use CodeIgniter , MySQL and Bootstrap 4 and it works properly until recently when the volume of data raised dramatically. Due to large amount data, one list page requires almost one minute to load all data. The PHP code behind the list page is:

function getproductlist() {
    $query = $this->db->select('prd.id id, prd.brand_name brand_name, prd.strength strength, prd.status status, prd.remarks remarks, com.company_name company_name, cat.category_name category_name, dos.type_name type_name')->from('bsoft_pharma_product prd')->join('bsoft_pharma_company com', 'prd.company_id = com.id', 'left')->join('bsoft_pharma_product_category cat', 'prd.category_id = cat.id', 'left')->join('bsoft_pharma_product_type dos', 'prd.dosage_id = dos.id', 'left')->get();
    return $query;
}

Where bsoft_pharma_product table contains around 27000 data, bsoft_pharma_company table contains 170 data, bsoft_pharma_product_category table contains 1200 data and finally bsoft_pharma_product_type table contains 112 data.

Can anyone tell me how can I optimize my query?
Thanks

As I think there might be some solutions you have to try...

Solution 1:

Load the page data only when user reach to the End of the page... Like: Google Images: [When we are viewing google images and we reach to the end of the page then some others images starts loading until the requested images types End.

Solution 2:

Convert the data to pagination like 20 / 30 records per page.

Solution 3:

Use some logo / animation loading tricks... like:

Use JavaScript to check the page loading percentage and then load something like: animation or company logo etc, so if the user have to wait then they don't feel boar or thinks that there is some issue in the page.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM