我有以下查询,在 phpmyadmin 中需要 0.055 秒,但在 CodeIgniter 中完全相同的查询需要 2 秒以上。有人知道问题可能是什么吗?
该查询仅提供大约 25 个结果,因此应该没有任何问题...
这是查询
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
编辑
这是我尝试在 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");
和
$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');