According to docs/database.txt (thanks Tim for writing this useful text), database reads should use wfGetDB( DB_SLAVE ). However, when browsing through the code, I found the following definition of Article::getDB() :
/** * Get the database which should be used for reads * * @return Database */ function &getDB() { $ret =& wfGetDB( DB_MASTER ); return $ret; }
As far as I can see, the Database object returned by this function is used to load the contents of the article.
Why is DB_MASTER used instead of DB_SLAVE?
Jitse
Brion Vibber wrote:
Jitse Niesen wrote:
Why is DB_MASTER used instead of DB_SLAVE?
Lagged slaves were too unreliable; you would often see the previous version after saving an edit.
Note that it in a typical page view, it only loads the page table row from the master. It then tries to load the revision and text rows from a slave using the up-to-date revision ID given by the master. If the revision is not present, it falls back to a load from the master. The overhead from doing this short, simple page table query to the master appears to be minimal. Most of the other operations in Article.php are write operations, and thus need the master connection.
-- Tim Starling
wikitech-l@lists.wikimedia.org