[Zope-Coders] Re: [ZCM] [ZC] 362/ 3 Comment "Indexes not used in the catalog"

Tres Seaver tseaver@zope.com
Wed, 24 Apr 2002 09:48:26 -0400 (EDT)


On Wed, 24 Apr 2002, Toby Dickenson wrote:

> (recipients list trimmed)
> 
> On Tue, 23 Apr 2002 19:00:50 -0400, "Collector: Zope Bugs, Features,
> and Patches ..." <zope-coders@zope.org> wrote:
> 
> >One of us is missing the other's point. The current optimization
> >assumes that an index is *only* interested in a request key that is
> >the same as the index id.
> 
> I think thats imprecise. The assumption is that the the value whose
> key is the same as his id is required to 'enable' that index. An index
> can look at other elements of the request dictionary, but only if it
> has been 'enabled'. Once 'enabled', it could completely ignore the
> value which caused it to be 'enabled' and only look at other values. 
> 
> >We can make this a requirement, but if we do so, we need to advertise
> >it. 
> 
> yes
> 
> >> - it is too much overhead to perform queries on indexes that
> >>   are not involved. 
> 
> >Why? Have you measured this? 
> 
> I have some plugin indexes that are *very* slow. Fortunately I dont
> reference them in most queries.

I think we should extend the contract of the index to add a method:

    def includeInQuery( self, REQUEST ):
        """
            Is this index interested in participating in this query?
        """

Otherwise, you push the knowledge of the "relevant" data for each
index out of its own domain, into that of the (indifferent) catalog.
The current heuristic makes it impractical to write plug-in indexes
which need to interact with *every* request, which forces one into
contortions like subclassing from ZCatalog in order to inject the
appropriate keys inside an overridden 'searchResults'.

All indexes should certainly be able toanswer this question much
more cheaply than calling '_applyIndex'.

Tres.
-- 
===============================================================
Tres Seaver                                tseaver@zope.com
Zope Corporation      "Zope Dealers"       http://www.zope.org