Php Symfony2 Doctrine2获取所有表

Php Symfony2 Doctrine2获取所有表,php,mysql,symfony,doctrine-orm,query-optimization,Php,Mysql,Symfony,Doctrine Orm,Query Optimization,我需要获取所有表并在循环中进行一些计算,下注的方法是什么,我的示例是: $em = $this->getDoctrine()->getManager(); $increment = 0; for($i = 0; $i>= 0; $i++){ $query = $em->createQueryBuilder() ->select('com') ->from('CatalogWebBundle:ComCompany',

我需要获取所有表并在循环中进行一些计算,下注的方法是什么,我的示例是:

$em = $this->getDoctrine()->getManager();

$increment = 0;

for($i = 0; $i>= 0; $i++){
    $query = $em->createQueryBuilder()
        ->select('com')
        ->from('CatalogWebBundle:ComCompany', 'com')
        ->getQuery()
        ->setMaxResults(2000)
        ->setFirstResult($increment);

    $info = $query->getArrayResult();
    if(!$info)
        break;
    $increment += 2000;
}
我得到的是:

查询速度不是很慢231ms,但PHP6501s如何优化这个时间到1-2s是可能的

这是我的表格结构:

CREATE TABLE IF NOT EXISTS `com_company` (
`cmp_id` int(11) NOT NULL,
  `cmp_category` int(11) DEFAULT NULL,
  `cmp_name` varchar(100) DEFAULT NULL,
  `cmp_code` int(10) DEFAULT NULL,
  `cmp_city` int(11) DEFAULT NULL,
  `cmp_vat` varchar(16) DEFAULT NULL,
  `cmp_emp` int(11) DEFAULT NULL,
  `cmp_return` varchar(255) DEFAULT NULL,
  `cmp_return_from` varchar(255) DEFAULT NULL,
  `cmp_return_till` varchar(255) DEFAULT NULL,
  `cmp_address` varchar(255) DEFAULT NULL,
  `cmp_phone` bigint(12) DEFAULT NULL,
  `cmp_email` varchar(100) DEFAULT NULL,
  `cmp_site` varchar(100) DEFAULT NULL,
  `cmp_ceo` varchar(50) DEFAULT NULL,
  `cmp_register` varchar(50) DEFAULT NULL,
  `cmp_url` varchar(100) NOT NULL
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=95749 ;


ALTER TABLE `com_company`
 ADD PRIMARY KEY (`cmp_id`), ADD KEY `cmp_city` (`cmp_city`), ADD KEY `cmp_category` (`cmp_category`);

ALTER TABLE `com_company`
MODIFY `cmp_id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=95749;

ALTER TABLE `com_company`
ADD CONSTRAINT `com_company_ibfk_1` FOREIGN KEY (`cmp_city`) REFERENCES `com_city` (`cit_id`),
ADD CONSTRAINT `com_company_ibfk_2` FOREIGN KEY (`cmp_category`) REFERENCES `com_category` (`cat_id`);
也许我的服务器太弱了?我需要将这个脚本优化到最多1-2秒,有可能吗

服务器:


Table-100k记录,Table size-23,6MIB我不清楚计算是必须用PHP代码完成,还是可以移动到SQL(例如MySQL过程)。但是如果是后者,我建议您看看MySQL过程。使用这种方法,您将在PHP客户端和MySQL服务器之间传输大量数据。最后,这不是一个非常可扩展的解决方案

我不能在mysql里面做这件事,这是复杂的计算,它的解决方案是在mysql->php之间进行快速传输?