[Zope-dev] RDB connections and cursors

Leonardo Rochael Almeida leo@hiper.com.br
19 Nov 2002 00:43:27 -0200


On Tue, 2002-11-19 at 00:19, Leonardo Rochael Almeida wrote:
> I've been having problems with RDB DAs performance and stability lately
> (stability mostly) and I was thinking of ways in which the use of
> connectors and cursors could be streamlined in Zope. I'm thinking about
> DB-API 2-like based DAs here.
> 
> >From what I understand of the way Zope handles requests and models
> concurrency and consistency, isn't it true that, for each DA connector
> in the OFS, I would need only one low level connector and one low level
> cursor per worker thread?
> 
> AFAIK, when a worker thread is calling objects in the course of handling
> a request, any sql methods that are called will have all its result rows
> converted to brains before returning, so a low level cursor involved in
> this query would be ready for another query, no need to get another
> cursor from the connector, isn't it right?
> 
> Assuming my reasoning above is correct we should be able to create a
> single connection and a single cursor on __setstate__ of the DA
> connector instance of the ZODB. The transaction boundaries would be
> handled normally, but since a worker thread only handles one request at
> a time, there's no need to close the cursor nor the connection at the
> transaction end.
> 
> What do you think?

We obviously need to close the cursor and the connector when the DA
connector object is removed from the Zope Object cache for that thread.
Are there hooks for this, other than the obvious one (__del__)?

Cheers, Leo