> It's almost surely not the Z SQL Method but the DTML rendering > that makes it slow. > Use an External Method to generate the HTML from the query > result. > Dieter Just out of curiosity: 1 - (technical) why would the external method by faster? 2 - (meta) rendering HTML is "the" DTML job, isn't it? bye, Luca.
At first, thanks to all who have replied to my questions, exspecially Stefano and Dieter. Now i know, thats not the Z SQL method that slows down, but the DTML-Batch-processing. As i told Stefano in a private response (forgot to change the to: in the reply :-), i have come to an acceptable state in the project., using an external method with the low-level mysql-module _mysql. code looks like this: db = _mysql.connect(<connect -parameters>) db.query(qs) l = db.store_result() l.data_seek(int(start)) x = l.fetch_row(amount) r = l.num_rows(), x db.close() return r qs is a generated querystring by passed parameters, dammned i cant use dtml-group here :-) start is the index of the first record to pass back to the dtml-in loop, amount the number of records to display on one page. i return a tuple with the number of all records selected, and the subset of records itself, so i can properly display the number of all records. the advantage in using the low-level module is, that the query only selects the records, and with fetch_row i can only retrieve the data i need to display on one page. but drawbacks are as follow: each query generates a new connection, no caching, no dtml-batch processing, this is done by hand with variables in the request-object passed by parameters on the links to the next-prev page. but it works and is acceptable fast. To Igor: to use an external method, create a .py file in the zope/Extensions directory, and define a function in it. then add this external method to your zope-project, with name of the file (without .py) and the name of the func. it is described in brief in the Zope-help and in "using Python based script - Using External Methods" in the Zope-book Part II, Chapter 10 "advanced Zope scripting", link is http://www.zope.org/Members/michel/ZB/ScriptingZope.dtml http://www.zope.org/Documentation/How-To/ExternalMethods is another link, explaining more, especially the important self-parameter. Thanks again to Stefano for the detailed info about the design of the app itself (its allways good to know what i am doing ... ;-) I hope i can change the whole design, restricting the use of the query-parameters, so i dont have to hack around anyhow. really thanks for your open words ! Rudi
in a nutshell, the external method will be faster because you can use it to circumvent security checking. when a large result from a ZSQL method is coming back to a page that renders it then zope will do a security check on every single item (not just every line) of that record to determine if the current user is allowed to see this item. so if your result set has 10,000 rows and 5 columns in each row then the security machinery will check 50,000 times. one exception where the security machinery will not check are simply python types (the return values from a ZSQL method are objects that contain the results and not simple types), such as strings, lists, dictionaries etc. so if you use an external method to get the result set and then convert it inside the external method to such a simple type and hand that back to DTML you will see a marked increase in speed. jens On Thursday, April 4, 2002, at 04:08 , Luca Manini wrote:
It's almost surely not the Z SQL Method but the DTML rendering that makes it slow.
Use an External Method to generate the HTML from the query result.
Dieter
Just out of curiosity:
1 - (technical) why would the external method by faster? 2 - (meta) rendering HTML is "the" DTML job, isn't it?
bye, Luca.
participants (3)
-
Jens Vagelpohl -
Luca Manini -
Rudi Wurm