Reputation: 818
I've got the following query, and in phpmyadmin it takes 0.055 seconds, but in CodeIgniter the exact same query takes more then 2 seconds. Anybody got an idea what the problem might be?
The query only gives about 25 results, so that shouldn't be any problem...
Here's the query
SELECT `Qty`, `Invt`, `ClassNr`, `SubPartCode`, `Description`, `DesignCode`, `Measure`, `Remark`, `PartMnem`
FROM (`loodvrij_receptuur` lr)
JOIN `loodvrij_artikel` la ON `la`.`PartCode` = `lr`.`SubPartCode`
WHERE `lr`.`PartCode` = 'M2430A'
ORDER BY `SubPartCode`, `Qty` desc
EDIT
This is the way I tried to execute the query in CodeIgniter
$this->db->query("SELECT `Qty`, `Invt`, `ClassNr`, `SubPartCode`, `Description`, `DesignCode`, `Measure`, `Remark`, `PartMnem`
FROM (`loodvrij_receptuur` lr)
JOIN `loodvrij_artikel` la ON `la`.`PartCode` = `lr`.`SubPartCode`
WHERE `lr`.`PartCode` = 'M2425B'
ORDER BY `SubPartCode`, `Qty` desc");
And
$this->db->select('Qty, Invt, ClassNr, SubPartCode, Description, DesignCode, Measure, Remark, PartMnem');
$this->db->from('loodvrij_receptuur lr');
$this->db->join('loodvrij_artikel la', 'la.PartCode = lr.SubPartCode');
$this->db->where('lr.PartCode', 'M2425B');
$this->db->order_by('SubPartCode');
$this->db->order_by('Qty', 'desc');
Upvotes: 0
Views: 1043
Reputation: 3412
you said the query gives only 25 results? does the table have only 25 results or more? Phpmyadmin automaticaly adds a limit clause, so it gives you only 20 something results. if your tables has more than 25 records, that maybe the culprit, because i don't see a limit clause in your ci query.
Upvotes: 3
Reputation: 17907
It might be that PHPMyAdmin accesses your database from a more direct route.
Upvotes: 0