1
$collection = Mage::getModel("customer/customer")->getCollection()
             ->addAttributeToSelect('firstname')
             ->addAttributeToFilter('grisk_college_new_id', array('in' =>$collegeid))
             ->addFieldToFilter('group_id', array('in' => array(4, 5)))
             ->addAttributeToFilter('physical_verify', array('null' => true), 'left')
             ->addFieldToFilter('assigned_campus_manager',array('like' => '%_/' . $custid . "%")); 

SELECT e.*, at_grisk_college_new_id.value AS grisk_college_new_id, at_physical_verify.value AS physical_verify, at_assigned_campus_manager.value AS assigned_campus_manager FROM customer_entity AS e INNER JOIN customer_entity_int AS at_grisk_college_new_id ON (at_grisk_college_new_id.entity_id = e.entity_id) AND (at_grisk_college_new_id.attribute_id = '275') LEFT JOIN customer_entity_int AS at_physical_verify ON (at_physical_verify.entity_id = e.entity_id) AND (at_physical_verify.attribute_id = '209') INNER JOIN customer_entity_varchar AS at_assigned_campus_manager ON (at_assigned_campus_manager.entity_id = e.entity_id) AND (at_assigned_campus_manager.attribute_id = '183') WHERE (e.entity_type_id = '1') AND (at_grisk_college_new_id.value IN('')) AND (e.group_id IN(4, 5)) AND (at_physical_verify.value IS NULL) AND (at_assigned_campus_manager.value LIKE '%_/%')

How can I make it more efficient ?

0

Use reset function:

$collection = Mage::getModel("customer/customer")->getCollection()
                 ->addAttributeToFilter('grisk_college_new_id', array('in' =>$collegeid))
                 ->addFieldToFilter('group_id', array('in' => array(4, 5)))
                 ->addAttributeToFilter('physical_verify', array('null' => true), 'left')
                 ->addFieldToFilter('assigned_campus_manager',array('like' => '%_/' . $custid . "%"));

    $collection ->getSelect()
     ->reset(Zend_Db_Select::COLUMNS)
     ->columns('firstname');
4
  • why you are using this reset , ? how does it work? May 13 '17 at 11:32
  • it will reset all column and just add those column which you require to select from db May 13 '17 at 11:35
  • will it reduce loading time ? May 13 '17 at 12:24
  • yes it will reduce time May 13 '17 at 12:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.