[Zope] cpu load 99 percent a lot in plone evinironment

Robert (Jamie) Munro jamie at textmatters.com
Mon Feb 12 14:12:20 EST 2007


Jens Vagelpohl wrote:
> 
> On 9 Feb 2007, at 09:29, Marko Kruijer wrote:
>>> I do notice that my suspected page is slow, but that's a page
>>> template, and there is not very much out of the ordinary going on
>>> there. Just a loop in tal over a sql result set.
> 
> "Just a loop in tal over a sql result set" can be extremely slow,
> depending on the size of your result set. You may not realize that every
> time you touch one of those resultset record objects the security
> machinery gets in the game to ensure the executing user is allowed to
> see the rendered result. This is true for every single field you're
> trying to show on the page.

I've been having similar speed problems with a page that loops through a
lot of SQL records. From what I can tell from the profiler, it is the
security machinery that is at fault.

> Workarounds I have used in this situation (eons ago) involved retrieving
> the resultset in trusted code (inside a filesystem product or an
> External Method) and converting it to a sequence of simple types, like a
> sequence of dictionaries, before handing it back to the page template.
> Those simple types don't cause security assertions and the rendering is
> sped up immensely.

There seems to be a built in method - .dictionaries() that does exactly
this. Unfortunatley, neither it, nor a simple external method I wrote to
 call my ZSQL methods seemed to help me.

Robert (Jamie) Munro



More information about the Zope mailing list