私のテーブルにcdbceriaを使用して結果をフェッチするのに約15000行ありますが、結果を読み込むのに時間がかかります。CDBcriteriaを使用してyiiでフェッチするのが非常に遅い
私はすべてのフェッチされた行の数とメソッドが最も速い結果をフェッチするようにしたい。助けてください!
$criteria = new CDbCriteria;
// $Criteria->$criteria = 50;
$currentAction = Yii::app()->controller->action->id;
if ($currentAction == 'currentstock') {
$storeid = isset(Yii::app()->session['storeId']) ? Yii::app()->session['storeId'] : 0;
$criteria->condition .= ' storexparts.storeId="' . $storeid . '" AND (partAppStatus="1" OR partAppStatus="15" OR partAppStatus="17" OR partAppStatus="22") ';
} else {
$userId = Yii::app()->user->id;
$storeid = isset(Yii::app()->session['storeId']) ? trim(Yii::app()->session['storeId']) : (isset($_REQUEST['storeId']) ? Yii::app()->session['storeId'] = trim($_REQUEST['storeId']) : '');
$criteria->condition = 'storexparts.storeId="' . $storeid . '"';
$criteria->condition .= ' AND userxfavparts.userId="' . $userId . '"';
$criteria->condition .= ' AND userxfavparts.storeId="' . $storeid . '"';
$criteria->condition .= ' AND (t.partAppStatus="1"';
$criteria->condition .= ' OR t.partAppStatus="15"';
$criteria->condition .= ' OR t.partAppStatus="17"';
$criteria->condition .= ' OR t.partAppStatus="22")';
// $criteria->order = 't.partCreateDate DESC';
}
$criteria->with = array('partUnit0', 'partCat0','fleetname', 'partType0', 'partSubCat0', 'storexparts', 'userxfavparts', 'partBrand0', 'partsalias','partPosXstore');
if (!empty($_GET['filterProperties'])) {
$string = implode("@", explode("\\", $_GET['filterProperties']));
$string = implode("@", explode("'", $string));
$code = stripslashes(trim($string));
$criteria->addCondition("partNumber LIKE CONCAT('%', :filterProperties , '%')
OR partsalias.aliasNumber LIKE CONCAT('%', :filterProperties , '%')
OR partType0.typeName LIKE CONCAT('%', :filterProperties , '%')
OR partCat0.catName LIKE CONCAT('%', :filterProperties , '%')
OR partSubCat0.subCatName LIKE CONCAT('%', :filterProperties , '%')
OR partDesc LIKE CONCAT('%', :filterProperties , '%')
OR storexparts.partQty LIKE CONCAT('%', :filterProperties , '%')
OR partNotes LIKE CONCAT('%', :filterProperties , '%')
OR partBrand0.brandCode LIKE CONCAT('%', :filterProperties , '%')
OR partUnit0.unitShort LIKE CONCAT('%', :filterProperties , '%')
OR partPosXstore.partShelf LIKE CONCAT('%', :filterProperties , '%')
OR partPosXstore.partBin LIKE CONCAT('%', :filterProperties , '%')
OR fleetname.fleetcode LIKE CONCAT('%', :filterProperties , '%')
OR fleetname.fleetserialno LIKE CONCAT('%', :filterProperties , '%')
OR fleetname.fleetmodel LIKE CONCAT('%', :filterProperties , '%')
OR fleettype0.typename LIKE CONCAT('%', :filterProperties , '%')
OR fleetbrand0.brandname LIKE CONCAT('%', :filterProperties , '%')
OR engine.engineno LIKE CONCAT('%', :filterProperties , '%')
OR partsalias.aliasBarcode LIKE CONCAT('%', :filterProperties , '%')
");
$criteria->params = array(':filterProperties' => $code);
}
$criteria->together = true;
if (isset($_REQUEST['Parts']) && !empty($_REQUEST['Parts'])) {
if (!empty($_REQUEST['Parts']['partAliasNumber'])) {
$partId = $_REQUEST['Parts']['partAliasNumber'];
$criteria->addCondition("partNumber LIKE CONCAT('%', :filterProperties , '%')
OR partsalias.aliasNumber LIKE CONCAT('%', :filterProperties , '%')");
$criteria->params = array(':filterProperties' => $partId);
}
}
$criteria->compare('partType0.typeName', $this->typeName, true, 'AND', 'LIKE');
$criteria->compare('partCat0.catName', $this->catName, true, 'AND', 'LIKE');
$criteria->compare('partSubCat0.subCatName', $this->subCatName, true, 'AND', 'LIKE');
$criteria->compare('partDesc', $this->partDesc, true, 'AND', 'LIKE');
$criteria->compare('storexparts.partQty', $this->partQty, true, 'AND', 'LIKE');
$criteria->compare('partNotes', $this->partNotes, true, 'AND', 'LIKE');
$criteria->compare('partUnit0.unitShort', $this->unitShort, true, 'AND', 'LIKE');
$criteria->compare('partBrand0.brandCode', $this->partBrand, true, 'AND', 'LIKE');
$criteria->compare('partPosXstore.partShelf', $this->partShelf, true, 'AND', 'LIKE');
$criteria->compare('partPosXstore.partBin', $this->partBin, true, 'AND', 'LIKE');