Tim Starling wrote:
After some indirect prompting from Erik, I wrote some link table update code which hopefully will speed up edits to pages with lots of links.
Yay!
- fairly well enabled/disabled with $wgUseBetterLinksUpdate
- Article::showArticle() loads the link table with LinkCache::preFill(),
then calls LinkCache::clear(), which clears the cache but leaves a copy of it hidden away. It then refills the cache with the new link table.
(Haven't looked at it in much detail yet.) Hmm, does this mean we take the overhead of a double cache on every page view? We should only need it when saving pages. I suppose in most cases it's the least of our troubles though. :)
- LinksUpdate::doUpdate() calls LinkCache::incrementalSetup(), which works
out what needs to be added and deleted, and applies a simple formula to decide whether the old way or the new way should be quicker.
- The new way deletes links row by row, and then adds the new ones using a
single insert. Blanking large articles would be slow, hence that would be done the old way.
It may be a touch more efficient to do the deletes in one query, such as: $sql = "DELETE FROM links WHERE l_from='{$this->mTitleEnc}' AND l_to IN (" . implode( ",", $del) . ")";
-- brion vibber (brion @ pobox.com)