[Zope] Z-SQL Method performance

Rudi Wurm net_seeker@web.de
Thu, 4 Apr 2002 14:30:53 +0200


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