Query Fragment Methods (QFM)
The number of database hits is a major factor in the performance of any
db application. Makumba (mostly the mak:list engine) is optimized to
generate the minimum possible number of queries.
In general, the number of queries should be independent of the data
size. This principle is sometimes broken when one needs to do a
supplementary query to find out more about a certain query result.
The idea of Query Fragment Methods is to actually not do queries, but
to append the existing query qith more query fragments to provide the
needed supplementary data which would have otherwise be obtained by
separate methods and queries.
The QFMs could be defined in MDDs as methods in an object-oriented way
(TODO: write these examples in a BEST -neutral manner)
in best.johnny.Application
acceptedFinal()
- finalPosition <= activ.finalPlaces
then in JSP we can do:
<mak:list from="best.johnny.Application applic" >
<mak:if expr="applic.acceptedFinal()" > ACCEPTED</mak:if>
</mak:list>
While the above is a simple expression that is simply pasted in the
query, a more complex example, with an argument, and more varied query
fragments can be thought of (never
mind the syntax, finding a suitable one is part of the brief)
in best.johnny.Student
acceptedFinal()
- args: best.johnny.Season season
- from: best.johnny.Application app
- where: app.stud=this AND app.activ.season=$season AND pp.acceptedFinal()
- result: count(app)>0
then in JSP
<mak:list from="best.johnny.Student s" >
<mak:value epxr="stud.acceptedFinal($season)">
<mak:value expr="s.name" />
</mak:list>
Brief
- write the above examples in BEST-independent manner (consider
e.g. auction items and bids)
- consider how QFMs would improve/simplify an existing application
- above there are only Read methods. Can Create, Update and Delete
(CRUD) methods be written equally well? This might not reduce the
number of DB hits
but it would provide uniformity
- consider the mathematics of query combination
- consider what would happen at type (MDD) inheritance. Can QFMs be
ovverriden?
- when you are satisfied, find an humanly-intuitive
machine-parseable syntax for QFMs