Come together with the global Drupal community in Rotterdam, 28 Sept – 1 Oct 2026. Sessions, contribution, connection, and Early Bird savings until 8 June.
The problem lies within the Zend Framework's Zend_Search_Lucene_Search_QueryHit class. The following examples illustrate how memory usage differs depending on how you retrieve field data from the Lucene document:
// $hits are the results returned from luceneapi_find()
// NOTE: Home page memory usage: 24285096
foreach ($hits as $hit) {
$value = $hit->nid;
}
echo memory_get_usage(); // 42294776
// after the same search is executed ...
foreach ($hits as $hit) {
$value = $index->getDocument($hit->id)->getFieldValue('nid');
}
echo memory_get_usage(); // 25824168
Although method #1 is used in most ZF examples, #2 is obviously much more efficient and also executes a bit more quickly. Search Lucene API now uses method #2 whenever possible, so upgrading to beta4 will show huge performance gains. This issue will be reported upstream to the Zend_Framework.
Comments
Comment #1
cpliakas commentedFixed in commit #286682.
The problem lies within the Zend Framework's Zend_Search_Lucene_Search_QueryHit class. The following examples illustrate how memory usage differs depending on how you retrieve field data from the Lucene document:
Although method #1 is used in most ZF examples, #2 is obviously much more efficient and also executes a bit more quickly. Search Lucene API now uses method #2 whenever possible, so upgrading to beta4 will show huge performance gains. This issue will be reported upstream to the Zend_Framework.
Comment #2
cpliakas commentedReported upstream at http://framework.zend.com/issues/browse/ZF-8267.