CodeIgniter Forums
heavy Query - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Best Practices (https://forum.codeigniter.com/forumdisplay.php?fid=12)
+--- Thread: heavy Query (/showthread.php?tid=1430)



heavy Query - fbmhm - 03-10-2015

Hi;
How to optimase my query in CodeIgniter;
Query takes a long time;

Demo:
http://www.eduserv.tn/espaces/index.php?login/etablissement/641802

Thks.


RE: heavy Query - CroNiX - 03-10-2015

We'd need to see the actual query along with the table schema for everything used in the query. Do you have indexes set on all fields that you are:
1) ordering by
2) joining on
3) selecting on

Proper indexing is how to really optimize the speed. If you only have indexes on your ID's, like autoincrementing fields, that isn't enough when you have a lot of data or complex queries. Without indexes the db engine has to scan every row in the table(s) to find what it's looking for, which can get exponentially complex depending on the joins and whatnot are used.


RE: heavy Query - fbmhm - 03-11-2015

Thks y for response;

can see on demo:

http://www.eduserv.tn/espaces/index.php?login/etablissement/64802

Profil: Etablissement
Login : [email protected]
Pass : IrELvcxV

(03-10-2015, 07:14 AM)CroNiX Wrote: We'd need to see the actual query along with the table schema for everything used in the query. Do you have indexes set on all fields that you are:
1) ordering by
2) joining on
3) selecting on

Proper indexing is how to really optimize the speed. If you only have indexes on your ID's, like autoincrementing fields, that isn't enough when you have a lot of data or complex queries. Without indexes the db engine has to scan every row in the table(s) to find what it's looking for, which can get exponentially complex depending on the joins and whatnot are used.



RE: heavy Query - spjonez - 03-15-2015

What he means is post the actual SQL query. A demo doesn't help without knowing how you've written the statement and what schema the tables are using.