Re: [Zope] SQLSession and Performance issues
timothy grant <tj-@avalongroup.net> wrote:
I am curious as to what methods may be used to reduce calls to SESSION['varname'], or if I am even barking up the right tree.
I guess it depends on what database you are using. If your database is a remote server hooked up through TCP/IP port, too many calls to SESSION could be bad. Also, if the session data is large, during the transimission many packets have to be send. I don't have an answer... maybe you could describe first what database you are using (Gadfly on the same machine? remote database?), do you do many retrievals and updates? ------------------------ In the code SQLSession.py, there is a 'caching' variable. SQLSession seems to cache variables that are already retrieved or are recently updated. Try to set 'caching' to 1 and see if that helps. ------------------------ As Pavlos Christoforou said, another strategy is to have a single session data variable (a dictionary, for instance), and then retrieve it, say, in your standard_html_header and store it in your standard_html_footer (or their equivalents.) This way you only need to access the database twice per request. ------------------------ Please post back... I am also very interested. You can also time performance by calling time.time() in Python or <dtml-var ZopeTime> in DTML. I am curious in the source of the problem... It would be nice to find out whether the time is spent in each database query or in TCP/IP packet splitting/joining/waiting. regards, Hung Jung ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com
Hung Jung Lu wrote:
I don't have an answer... maybe you could describe first what database you are using (Gadfly on the same machine? remote database?), do you do many retrievals and updates?
PostgreSQL running on the same box as ZServer.
In the code SQLSession.py, there is a 'caching' variable. SQLSession seems to cache variables that are already retrieved or are recently updated. Try to set 'caching' to 1 and see if that helps.
Thanks for this input. I will go and take a look at it. I did not know it was there.
As Pavlos Christoforou said, another strategy is to have a single session data variable (a dictionary, for instance), and then retrieve it, say, in your standard_html_header and store it in your standard_html_footer (or their equivalents.) This way you only need to access the database twice per request.
Now this in an interesting idea, but all my attempts to computationally build a dictionary within Zope have gone to naught. I would love any advice on this as I believe it could very well be the key to this problem. -- Stand Fast, tjg. Chief Technology Officer tjg@exceptionalminds.com Red Hat Certified Engineer www.exceptionalminds.com Avalon Technology Group, Inc. (503) 246-3630
>>>>>>Linux...Because rebooting isn't normal<<<<<<<<<<<<
Timothy Grant wrote:
Hung Jung Lu wrote:
As Pavlos Christoforou said, another strategy is to
have a single session data variable (a dictionary, for instance), and then retrieve it, say, in your standard_html_header and store it in your standard_html_footer (or their equivalents.) This way you only need to access the database twice per request.
Now this in an interesting idea, but all my attempts to computationally build a dictionary within Zope have gone to naught. I would love any advice on this as I believe it could very well be the key to this problem.
To build a dict in DTML, try something like this: <dtml-var standard_html_header> <dtml-call "REQUEST.set('mydict',{})"> <dtml-call "mydict.update({'e':7})"> <dtml-with mydict mapping> [<dtml-var e>] </dtml-with> <dtml-var standard_html_footer> Plain python assignment won't work, as a "=" in python is a statement, and statements are not supported, only function calls. to remove a key, use <dtml-call "del(mydict['e'])"> ----------------- Hannu
Hannu Krosing wrote:
To build a dict in DTML, try something like this:
<dtml-var standard_html_header> <dtml-call "REQUEST.set('mydict',{})">
<dtml-call "mydict.update({'e':7})">
<dtml-with mydict mapping> [<dtml-var e>] </dtml-with>
<dtml-var standard_html_footer>
Plain python assignment won't work, as a "=" in python is a statement, and statements are not supported, only function calls.
to remove a key, use <dtml-call "del(mydict['e'])">
Aha! the missing piece of the puzzle, thanks so much for your time and the enlightenment. It is really appreciated.. -- Stand Fast, tjg. Chief Technology Officer tjg@exceptionalminds.com Red Hat Certified Engineer www.exceptionalminds.com Avalon Technology Group, Inc. (503) 246-3630
>>>>>>Linux...Because rebooting isn't normal<<<<<<<<<<<<
participants (3)
-
Hannu Krosing -
Hung Jung Lu -
Timothy Grant