Go
Decent Blogging using Foswiki Read on
20 Oct 2005 - 18:04 in tagged , , by Michael Daum
The first try to do a decent TWikiApplication was solely based on SEARCH and INCLUDE. But that got very slow. There where a dozen SEARCHes for a single page to collect all stuff...
And actually using the DBCacheContrib is BestPractice for TWikiApplications. Sometimes you have to come a long way to accept a truth. Kudos to CrawfordCurrie, the author of this marvelous plugin!!! So I installed the DBCacheContrib and its cousin the FormQueryPlugin ... to find out that the much I admired the first the much I got convinced that the latter is - how should I say it friendly - somehow bloated. Overkill. The DBCacheContrib itself has all that I needed: automatic formfield caching and a way to query them. As this functions are not available in its simple form to TWikiML I wrote an extension tag DBQUERY which does the job similar to the good old SEARCH. So porting a SEARCH expression to a DBQUERY expression was straight-forward with only minor changes to the format expressions which where all in place already for this blog.

Adding the DBQUERY resulted in some interesting simplifications of the TopicFunctions some of which could be completely be replaced with a single DBQUERY expression, notably the getter TopicFunctions being obsoleted.

Counting topics matching a search string was a separate tag before COUNTTOPICS. Obsolete too now. The BlogPlugin has seen some rewriting too which was not so straight forward as rewriting the TopicFunctions. There was a central function query() which formatted a SEARCH string and then called expandCommonVariables() and parsed the result into a result array. This function is history and is replaced by a dbQuery() which is the workhorse of the DBQUERY tag but also used internaly.

The only thing that needed to be rewritten was the RECENTCOMMENTS tag which was performing very poorly and was braindead anyway. But using the DBCacheContrib API made it a breath to implement something that does its job much more efficient, but acctually not based on dbQuery() as it does only simple queries and the RECENTCOMMENTS logic would be a nested one in SQL. But even that would have been overkill as the innter query would just be there to fetch exactly one record to check if it has a certain property. The best implementation would therefore still be O(n) and not O(n2).

Right now, the DBQUERY tag is build into the BlogPlugin, but obviously this should go into a DBQueryPlugin. The TIMESINCE tag should be externalized also into a TimeSincePlugin. Sigh.


Leave a Reply

You may have to login or register to comment if you haven't already.
r4 - 27 Feb 2006 - 16:12:50 - Main.MichaelDaum
Copyright © 1999-2012 Michael Daum Consulting. All rights reserved. Impressum.