I have a BaseX backed website which stores all the pieces of the page in the DB. There is a significant amount of processing to be done. Pretty much any piece of the page can have effective or expiration dates (so that page parts can come and go on schedule). Some pages have dynamic elements, such as a Twitter feed. The page is build from objects which are wrapped in frames (for adding temporal and styling parameters), which are inserted into columns, which go into rows, which make up a page (which itself is wrapped in a template). So there is a lot of recursion.
I do the recursion using local functions.
It works well, but the page-building query is getting enormous, most of which is all these functions to insert parts of the page, often recursively.
I am wondering what the best practice would be for this. I'm working in Scala, and I could break the process up into repeated passes hitting the db with a different query for each, but it seems to me one big query will almost certainly be faster. But including all the local functions in the query makes it huge.
Is there some way to compile and load the functions once on startup, and then just run a small XQuery that calls functions which call functions, etc.?
Any ideas (or resources) for ways to optimize the query? Everything gets reused, so there is very little nesting -- mostly references are passed. For example:
<pages>
<page>
<id>1</id>
<rows>
<row id="2"/>
<row id="3"/>
</rows>
</page>
</pages>
<rows>
<row>
<id>2</id>
<columns>
<column width="18">
<frames>
<frame id="4"/>
<frame id="5"/>
</frames>
</column>
<column width="6">
<frames>
<frame id="6/>
</frames>
</column>
</columns>
</row>
</rows>
<frames>
<frame>
<id>4</id>
<contents>
<content id="7"/>
</contents>
</frame>
</frames>
<contents>
<content type="TEXT"/>
<id>7</id>
<body>
<p>Some text here.</p>
</body>
</content>
<content type="WIDGET"/>
<id>7</id>
<!-- Widget parameters here -->
</content>
</contents>
Thanks!
Chas.
_______________________________________________
BaseX-Talk mailing list
BaseX-Talk@mailman.uni-konstanz.dehttps://mailman.uni-konstanz.de/mailman/listinfo/basex-talk