Hmm. I didn't realize there is a way to remove $smwgQDefaultNamespaces restriction and this will enable all namespaces instead of disabling them.

Why is it that this setting not set to NULL by default then? I don't see any point in restricting namespaces unless it's absolutely necessary for security reasons or something.


On Dec 29, 2007 10:29 AM, Markus Krötzsch <> wrote:
On Freitag, 28. Dezember 2007, Lau, William (NIH/CIT) [E] wrote:
> We have a set of semantic queries in a template. That template is used
> in some pages. However, by looking at the database process list, it
> seems that those set of queries are processed whenever a page is
> requested, even when the template is not used by the requested page
> (e.g. special pages).

Do I understand this correctly? The delivery of special pages that are
completely unrelated to said template triggers the ask-queries contained
therein? This would be very strange behaviour indeed (I cannot currently
imagine how or why this should happen in MediaWiki)!

> All the SQL queries are generated by the
> getQueryResult function. Since those queries are very computational
> intensive, this "bug" slows down the entire site. If we take the inline
> queries out of the template or change $smwgQEnabled to false, the site
> becomes fast again. Has anyone experienced the same issue?

In general, if queries on some site are too slow, it is useful to configure
SMW to support faster querying (with less features, of course). Basic
settings one can try to speed up querying are:

$smwgQSubcategoryDepth = 0;
$smwgQSubpropertyDepth = 0;
$smwgQEqualitySupport = SMW_EQ_NONE;
$smwgQDefaultNamespaces = NULL;

Those settings will speed up basically all queries, disabling all support for
property and category hierarchies, equality (redirects), and namespace
restrictions (i.e. queries consider pages in all namespaces, including, e.g.,
User:). You can experiment which of those, if any, affects your query
performance positively.

If you have problems with too complex user-generated queries, then the
parameters $smwgQMaxSize and $smwgQMaxDepth are an option to restrict this.

In general, it should be emphasised that queries should be used in a targetted
way. had the infamous template {{ask}} for some time, which
included queries for almost anything, which would just not appear if no
results would be obtained. Most wikis should rather have single query
templates for special purposes instead of trying to have one for all.

Anyway, for further optimisation, we need some pointer to your site, or at
least some statistical information concerning its size
(Special:SemanticStatistics) and the query structure. Did you mention the SMW
version you use? Some of the above assume SMW1.0-RC3, and none will work
prior to SMW1.0-RC1.


Markus Krötzsch
Institut AIFB, Universät Karlsruhe (TH), 76128 Karlsruhe
phone +49 (0)721 608 7362        fax +49 (0)721 608 5998        www

This email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
Semediawiki-devel mailing list

Sergey Chernyshev