Forums / Developer / Slow down / Comment50227

Author Topic

André R.

Thursday 02 October 2008 9:27:22 am

Comment50227

You are doing a sql call pr node, with 500 000 nodes that adds 500 000 sql calls, about 499 500 above what is recommended as maximum pr page..
You should instead fetch it once before the loop and return the result as a keyed array (where object_id is key) to be used inside the loop.

To be able to do that you'll need to GROUP BY the object id so you can get both count and object id in the sql result.

Like this only with COUNT instead of SUM:
http://www.w3schools.com/sql/sql_groupby.asp

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom