"Eduard Witteveen" wrote:
> On Fri, 2002-08-09 at 16:30, Marcel Maatkamp wrote:
> >         // virtual node -> real node
> >         Enumeration e = tussenresults.elements();
> >         while(e.hasMoreElements())
> >             results.addElement( 
>this.parent.getNode(((MMObjectNode)e.nextElement()).getStringValue(type+".number")) );
> > 
> >         return results;
> >     }
> This can produce a lot of select * from the database. Maybe we should
> change it to something like 
> return ((MMObjectBuilder)getModule(type)).search("where number in (" +
> foundNumbers + ")"); ?
When we use getNode performance might be less than with the use of a
where number in construct, but the good thing is that you pull in the right nodes
if you have a builder extending another builder. Say you have a MediaClip
base builder and a AudioClip builder extending the MediaClip builder.
With getNode you pull the AudioClips from the db into memory, with a
'where number in' construct you only retrieve the MediaClip base part
of the nodes. (If you listed the related MediaClips)

So using getNodes will indeed result in more queries if the nodes are not
yet in memory, but you gain that you are fetching the right nodes. Without
going into further implementation details, the gain compared with the current
situation is really, really huge. A reallife example: We have a quiz with 2500 
questions related to the quiz. If you play the quiz a player will be related to
the quiz, so say you have 2500 players related to the quiz. Now to build
a page for the quiz you relate a image to the quiz. To list this single related
image, after a fresh start, MMBase now sends 10.000(!!!!!!!!!!!!!!) SQL
queries to the db to get this single related image, in the new implementation
this would be reduced to 2 :)

Wilbert Hengst - [EMAIL PROTECTED]  VPRO-Digitaal - www.vpro.nl
Phone: +31-35-6712728  Fax:+31-35-6712733
Visit: Mediapark, Sumatralaan 45, Hilversum, The Netherlands
Mail: P.O.box 11, 1200 JC Hilversum, The Netherlands


Reply via email to