Skip to content
Snippets Groups Projects
Commit ff2fc936 authored by Laurent's avatar Laurent
Browse files

performances: use count(*) instead of count(id) as MySQL can use index keys

parent dd2a4fdd
Branches
1 merge request!22Perfs phpunit
Pipeline #4685 passed with stage
......@@ -105,7 +105,7 @@ class Storm_Model_PersistenceStrategy_Db extends Storm_Model_PersistenceStrategy
return 0;
$select->from($this->getTable(),
[sprintf('count(%s) as numberof', $this->_loader->getIdField())]);
[sprintf('count(*) as numberof')]);
$rows = $this->getTable()->fetchAll($select)->toArray();
return $rows[0]['numberof'];
}
......
......@@ -52,7 +52,7 @@ class Storm_Test_LoaderTest extends Storm_Test_ModelTestCase {
public function countByWithWhereShouldBuildRightSQL() {
$select = Storm_Test_ObjectWrapper::mock()
->whenCalled('from')
->with($this->_table, array('count(id) as numberof'))
->with($this->_table, ['count(*) as numberof'])
->answers(null)
->whenCalled('where')
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment