Very slow if $data is big |
Thanks everyone for wanting to help me!
My main query looks like this: Code: SELECT `c`.*, `p`.`nom` as `projet_nom`, `p`.`entente_paiement`, GROUP_CONCAT(cc.id_client SEPARATOR "|") AS id_clients, `cie`.`nom` as `cie_nom`, `f`.`id` as `id_facture`, `f`.`date_envoi`, `f`.`total`, `f`.`date_facture`, `ff`.`id` as `id_facture_finale`, `ff`.`total` as `total_finale`, `ff`.`date_facture` as `date_facture_finale`, `au`.`first_name` as `user_prenom`, `au`.`last_name` as `user_nom`, `au2`.`first_name` as `verif_prenom`, `au2`.`last_name` as `verif_nom`, `ef`.`id_encaissement`, SUM(ef.montant) as montant_encaissement, `ef2`.`id_encaissement` as `id_encaissement_finale`, SUM(ef2.montant) as montant_encaissement_finale, MAX(cp.date_prolongation) as date_prolongation FROM `commandes` `c` LEFT JOIN `projets` as `p` ON `c`.`id_projet` = `p`.`id` LEFT JOIN `compagnies` as `cie` ON `cie`.`id` = `p`.`id_compagnie` LEFT JOIN `commandes_prolongation` as `cp` ON `c`.`id` = `cp`.`id_commande` LEFT JOIN `commandes_clients` `cc` ON `cc`.`id_commande` = `c`.`id` LEFT JOIN `factures` `f` ON `f`.`id_commande` = `c`.`id` AND `f`.`type` = "commande" LEFT JOIN `factures` `ff` ON `ff`.`id_commande` = `c`.`id` AND `ff`.`type` = "finale" LEFT JOIN `encaissements_factures` `ef` ON `f`.`id` = `ef`.`id_facture` AND `ef`.`type` = "facture" LEFT JOIN `encaissements_factures` `ef2` ON `ff`.`id` = `ef2`.`id_facture` AND `ef2`.`type` = "facture" LEFT JOIN `auth_users` `au` ON `au`.`id` = `c`.`created_by` LEFT JOIN `auth_users` `au2` ON `au2`.`id` = `c`.`verificateur` GROUP BY `c`.`id` It join 11 tables, but the query is executing very fast (0,0056 second(s)). It gave 415 results. I'm using the datas passed to the view to load a table of orders (rental of products), indicating the number of products, the total of the invoices, the list of the clients associated with the orders, the balance of each order, etc. I know that the problem comes from the amount of data passed to the view because when I empty the view (showing only the HTML frame with no data), it's still very slow. When I'm doing a query with not a lot of results, the page loads at a normal speed. Another problem that I have is that I'm calling 4 queries before the page loads. One other query makes it slow (multiple array sent to the view is too big). So when I'm loading the page, it's very very slow. My clients tell me that it takes almost 30 seconds to load. On my side, it's a bit quicker but I have a very fast computer. Thanks for your help and suggestions!
--
MarieveStrange Web Programmer |
Welcome Guest, Not a member yet? Register Sign In |