Audra,

Can you describe the size of your wiki and amount of redirects? 34 minutes seems to be a huge number.
Can you also give an example of SMW query that ran that long?

          Sergey



On Nov 18, 2007 7:05 PM, Audra Johnson <audra@audrajohnson.com> wrote:
A few weeks ago, I discovered that searches with a few subqueries
were dreadfully slow and found the cause to be making annotated
redirects equivalent to their targets.  I suggested making redirect
equivalency a SMW option--but when I went scanning for how to
implement it, I gleefully found that it was already included!  The
setting is:

$smwgQEqualitySupport = true; // Should #redirects be evaluated as
equality between page names?

(It should probably include a note about efficiency for its comment,
just like the one for $smwgQDefaultNamespaces--taking out redirect
equality support can make a HUGE difference for more complex
queries.  HUGE being the difference between a three subquery search
taking 34 minutes with redirect equivalency and .3 seconds without.)

In any case, my semantic wiki has been happily humming and searching
along since I set $smwgQEqualitySupport to false.    But I also need
a way to tell where annotations in the wiki are pointing to
redirected pages, so they can be fixed.

So I've made a special page for redirected annotations that extends
SMWQueryPage.  This will make it easy for people to find where
annotations are pointing to redirected pages and fix them to point at
the right ones.

Messages that would are added for this page:

       // Messages for Redirected Annotations Special
       'redirectedannotations' => 'Redirected annotations',
       'smw_redirectedannotations_docu' => 'The object of these annotations
points to a redirected page.',
       'smw_redirectedannotations_template' => 'On page $1, the annotation
$2::$3 redirects to $4.',

It required one additional function to SMW_SQLStore in the "Special
page functions" section:

function getRedirectedAnnotationsSpecial($requestoptions = NULL) {
               wfProfileIn("SMWSQLStore::getRedirectedAnnotationsSpecial (SMW)");
               $db =& wfGetDB( DB_SLAVE );
               $options = ' ORDER BY subject_title';

               if ($requestoptions->limit > 0) {
                       $options .= ' LIMIT ' . $requestoptions->limit;
               }
               if ($requestoptions->offset > 0) {
                       $options .= ' OFFSET ' . $requestoptions->offset;
               }

               extract( $db->tableNames('smw_relations', 'redirect') );

               $res = $db->query("SELECT subject_title, subject_namespace,
relation_title, object_title, object_namespace, rd_title,
rd_namespace FROM $smw_relations "
                       . "INNER JOIN $redirect ON $smw_relations.object_id =
$redirect.rd_from"
                       . $options, 'SMW::getRedirectedAnnotationsSpecial');
               $result = array();

               while($row = $db->fetchObject($res)) {
                       $subject_page = Title::newFromText($row->subject_title, $row-
 >subject_namespace);
                       $relation_page = Title::newFromText($row->relation_title,
SMW_NS_PROPERTY);
                       $object_page = Title::newFromText($row->object_title, $row-
 >object_namespace);
                       $rd_page = Title::newFromText($row->rd_title, $row->rd_namespace);
                       $result[] = array($subject_page, $relation_page, $object_page,
$rd_page);
               }

               wfProfileOut("SMWSQLStore::getRedirectedAnnotationsSpecial (SMW)");
               return $result;
       }

And it needs to be added in the enableSemantics() function in
SMW_GlobalFunctions.php:

$wgSpecialPages['RedirectedAnnotations']       = array
('SMWSpecialPage','RedirectedAnnotations',
'smwfDoSpecialRedirectedAnnotations', $smwgIP . '/specials/QueryPages/
SMW_SpecialRedirectedAnnotations.php');

I've attached the PHP code for the page itself.

Am looking for input on:

* Whether the special page should be initialized and included only if
$smwgQEqualitySupport = false
* Whether the page name RedirectedAnnotations is an adequate name
* Other wording that should be changed or tweaked.  For example, in
the smw_redirctedannotations_temp:
* Message text:  "the annotation Similar to::X redirects to Y." or
"the relation Similar to::X redirects to Y.", since this only happens
to relation annotations? "The object of these annotations points to a
redirected page." or "The object of these relations points to a
redirected page." ?
* Coding style



-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Semediawiki-devel mailing list
Semediawiki-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/semediawiki-devel




--
Sergey Chernyshev
http://www.sergeychernyshev.com/