MediaWiki  1.28.0
docs/database.txt File Reference

Functions

$dbw begin (__METHOD__)
 
$dbw commit (__METHOD__)
 
 foreach ($res as $row)
 
$dbw insert ()
 
We use the convention $dbr for
read and $dbw for write to
help you keep track of whether
the database object is a the
world will explode Or to be a
subsequent write query which
succeeded on the master may
fail when replicated to the
slave due to a unique key
collision Replication on the
slave will stop and it may
take hours to repair the
database and get it back
online Setting read_only in my
cnf on the slave will avoid
this but given the dire we
prefer to have as many checks
as possible We provide a but
the wrapper functions like
please read the documentation
for except in special pages
derived from QueryPage It s a
common pitfall for new
developers to submit code
containing SQL queries which
examine huge numbers of rows
Remember that COUNT * 
is (N), counting rows in atable is like counting beans in a bucket.------------------------------------------------------------------------Replication------------------------------------------------------------------------The largest installation of MediaWiki, Wikimedia, uses a large set ofslave MySQL servers replicating writes made to a master MySQL server.Itis important to understand the issues associated with this setup if youwant to write code destined for Wikipedia.It's often the case that the best algorithm to use for a given taskdepends on whether or not replication is in use.Due to our unabashedWikipedia-centrism, we often just use the replication-friendly version, but if you like, you can use wfGetLB() ->getServerCount() > 1 tocheck to see if replication is in use.===Lag===Lag primarily occurs when large write queries are sent to the master.Writes on the master are executed in parallel, but they are executed inserial when they are replicated to the slaves.The master writes thequery to the binlog when the transaction is committed.The slaves pollthe binlog and start executing the query as soon as it appears.They canservice reads while they are performing a write query, but will not readanything more from the binlog and thus will perform no more writes.Thismeans that if the write query runs for a long time, the slaves will lagbehind the master for the time it takes for the write query to complete.Lag can be exacerbated by high read load.MediaWiki's load balancer willstop sending reads to a slave when it is lagged by more than 30 seconds.If the load ratios are set incorrectly, or if there is too much loadgenerally, this may lead to a slave permanently hovering around 30seconds lag.If all slaves are lagged by more than 30 seconds, MediaWiki will stopwriting to the database.All edits and other write operations will berefused, with an error returned to the user.This gives the slaves achance to catch up.Before we had this mechanism, the slaves wouldregularly lag by several minutes, making review of recent editsdifficult.In addition to this, MediaWiki attempts to ensure that the user seesevents occurring on the wiki in chronological order.A few seconds of lagcan be tolerated, as long as the user sees a consistent picture fromsubsequent requests.This is done by saving the master binlog positionin the session, and then at the start of each request, waiting for theslave to catch up to that position before doing any reads from it.Ifthis wait times out, reads are allowed anyway, but the request isconsidered to be in"lagged slave mode".Lagged slave mode can bechecked by calling wfGetLB() ->getLaggedSlaveMode().The onlypractical consequence at present is a warning displayed in the pagefooter.===Lag avoidance===To avoid excessive lag, queries which write large numbers of rows shouldbe split up, generally to write one row at a time.Multi-row INSERT...SELECT queries are the worst offenders should be avoided altogether.Instead do the select first and then the insert.===Working with lag===Despite our best efforts, it's not practical to guarantee a low-lagenvironment.Lag will usually be less than one second, but mayoccasionally be up to 30 seconds.For scalability, it's very importantto keep load on the master low, so simply sending all your queries tothe master is not the answer.So when you have a genuine need forup-to-date data, the following approach is advised:1) Do a quick query to the master for a sequence number or timestamp 2) Run the full query on the slave and check if it matches the data you gotfrom the master 3) If it doesn't, run the full query on the masterTo avoid swamping the master every time the slaves lag, use of thisapproach should be kept to a minimum.In most cases you should just readfrom the slave and let the user deal with the delay.------------------------------------------------------------------------Lock contention------------------------------------------------------------------------Due to the high write rate on Wikipedia(and some other wikis), MediaWiki developers need to be very careful to structure their writesto avoid long-lasting locks.By default, MediaWiki opens a transactionat the first query, and commits it before the output is sent.Locks willbe held from the time when the query is done until the commit.So youcan reduce lock time by doing as much processing as possible before youdo your write queries.Often this approach is not good enough, and it becomes necessary toenclose small groups of queries in their own transaction.Use thefollowing syntax:$dbw=wfGetDB(DB_MASTER
 
We use the convention $dbr for
read and $dbw for write to
help you keep track of whether
the database object is a the
world will explode Or to be a
subsequent write query which
succeeded on the master may
fail when replicated to the
slave due to a unique key
collision Replication on the
slave will stop and it may
take hours to repair the
database and get it back
online Setting read_only in my
cnf on the slave will avoid
this but given the dire we
prefer to have as many checks
as possible We provide a 
query () function for raw SQL
 
Use of locking reads (e.g.the FOR UPDATE clause) is not advised.They are poorly implemented in InnoDB and will cause regular deadlock errors.It's also surprisingly easy to cripple the wiki with lock contention.Instead of locking reads
 
We use the convention $dbr for
read and $dbw for write to
help you keep track of whether
the database object is a the
world will explode Or to be a
subsequent write query which
succeeded on the master may
fail when replicated to the
slave due to a unique key
collision Replication on the
slave will stop and it may
take hours to repair the
database and get it back
online Setting read_only in my
cnf on the slave will avoid
this but given the dire we
prefer to have as many checks
as possible We provide a but
the wrapper functions like 
select () and insert() are usually more convenient.They take care of things like table prefixes and escaping for you.If you really need to make your own SQL
 
We use the convention $dbr for
read and $dbw for write to
help you keep track of whether
the database object is
slave (read-only) or a master(read/write).If you write to a slave
 
We use the convention $dbr for
read and $dbw for write to
help you keep track of whether
the database object is a the
world will explode Or to be a
subsequent write query which
succeeded on the master may
fail when replicated to the
slave due to a unique key
collision Replication on the
slave will stop and it may
take hours to repair the
database and get it back
online Setting read_only in my
cnf on the slave will avoid
this but given the dire we
prefer to have as many checks
as possible We provide a but
the wrapper functions like
please read the documentation
for 
tableName () and addQuotes().You will need both of them.------------------------------------------------------------------------Basic query optimisation------------------------------------------------------------------------MediaWiki developers who need to write DB queries should have some understanding of databases and the performance issues associated with them.Patches containing unacceptably slow features will not be accepted.Unindexed queries are generally not welcome in MediaWiki
 

Variables

 $res = $dbr->select( )
 
We use the convention $dbr for
read and $dbw for write to
help you keep track of whether
the database object is a the
world will explode Or to be a
subsequent write query which
succeeded on the master may
fail when replicated to the
slave due to a unique key
collision Replication on the
slave will stop and it may
take hours to repair the
database and get it back
online Setting read_only in my
cnf on the slave will avoid
this but given the dire 
consequences
 
Some information about
database access in MediaWiki
By Tim January Database layout
For information about the
MediaWiki database such as a
description of the tables and
their 
contents
 
Some information about
database access in MediaWiki
By Tim January Database layout
For information about the
MediaWiki database 
layout
 
For a write use something like
 
We use the convention $dbr for
read and $dbw for write to
help you keep track of whether
the database object is a the
world will explode Or to be 
precise
 
Use of locking combine your
existence checks into your
write 
queries
 
For a write query
 
We use the convention $dbr for
read and $dbw for write to
help you keep track of whether
the database object is a the
world will explode Or to be a
subsequent write query which
succeeded on the master may
fail when replicated to the
slave due to a unique key
collision Replication on the
slave will stop and it may
take hours to repair the
database and get it back
online Setting read_only in my
cnf on the slave will avoid
this 
scenario
 
Some information about
database access in MediaWiki
By Tim January Database layout
For information about the
MediaWiki database such as a
description of the tables and
their please 
see
 
Some information about
database access in MediaWiki
By Tim 
Starling
 
Some information about
database access in MediaWiki
By Tim January Database layout
For information about the
MediaWiki database such as a
description of the tables and
their please something like
this usually 
suffices
 

Function Documentation

$dbw commit ( __METHOD__  )
foreach (   $res as)

Definition at line 22 of file database.txt.

$dbw insert ( )
We use the convention $dbr for read and $dbw for write to help you keep track of whether the database object is a the world will explode Or to be a subsequent write query which succeeded on the master may fail when replicated to the slave due to a unique key collision Replication on the slave will stop and it may take hours to repair the database and get it back online Setting read_only in my cnf on the slave will avoid this but given the dire we prefer to have as many checks as possible We provide a but the wrapper functions like please read the documentation for except in special pages derived from QueryPage It s a common pitfall for new developers to submit code containing SQL queries which examine huge numbers of rows Remember that COUNT* is ( ) -> getServerCount() > 1 tocheck to see if replication is in use.===Lag===Lag primarily occurs when large write queries are sent to the master.Writes on the master are executed in parallel, but they are executed inserial when they are replicated to the slaves.The master writes thequery to the binlog when the transaction is committed.The slaves pollthe binlog and start executing the query as soon as it appears.They canservice reads while they are performing a write query, but will not readanything more from the binlog and thus will perform no more writes.Thismeans that if the write query runs for a long time, the slaves will lagbehind the master for the time it takes for the write query to complete.Lag can be exacerbated by high read load.MediaWiki's load balancer willstop sending reads to a slave when it is lagged by more than 30 seconds.If the load ratios are set incorrectly, or if there is too much loadgenerally, this may lead to a slave permanently hovering around 30seconds lag.If all slaves are lagged by more than 30 seconds, MediaWiki will stopwriting to the database.All edits and other write operations will berefused, with an error returned to the user.This gives the slaves achance to catch up.Before we had this mechanism, the slaves wouldregularly lag by several minutes, making review of recent editsdifficult.In addition to this, MediaWiki attempts to ensure that the user seesevents occurring on the wiki in chronological order.A few seconds of lagcan be tolerated, as long as the user sees a consistent picture fromsubsequent requests.This is done by saving the master binlog positionin the session, and then at the start of each request, waiting for theslave to catch up to that position before doing any reads from it.Ifthis wait times out, reads are allowed anyway, but the request isconsidered to be in"lagged slave mode".Lagged slave mode can bechecked by calling wfGetLB() ->getLaggedSlaveMode().The onlypractical consequence at present is a warning displayed in the pagefooter.===Lag avoidance===To avoid excessive lag, queries which write large numbers of rows shouldbe split up, generally to write one row at a time.Multi-row INSERT...SELECT queries are the worst offenders should be avoided altogether.Instead do the select first and then the insert.===Working with lag===Despite our best efforts, it's not practical to guarantee a low-lagenvironment.Lag will usually be less than one second, but mayoccasionally be up to 30 seconds.For scalability, it's very importantto keep load on the master low, so simply sending all your queries tothe master is not the answer.So when you have a genuine need forup-to-date data, the following approach is advised:1) Do a quick query to the master for a sequence number or timestamp 2) Run the full query on the slave and check if it matches the data you gotfrom the master 3) If it doesn't, run the full query on the masterTo avoid swamping the master every time the slaves lag, use of thisapproach should be kept to a minimum.In most cases you should just readfrom the slave and let the user deal with the delay.------------------------------------------------------------------------Lock contention------------------------------------------------------------------------Due to the high write rate on Wikipedia(and some other wikis), MediaWiki developers need to be very careful to structure their writesto avoid long-lasting locks.By default, MediaWiki opens a transactionat the first query, and commits it before the output is sent.Locks willbe held from the time when the query is done until the commit.So youcan reduce lock time by doing as much processing as possible before youdo your write queries.Often this approach is not good enough, and it becomes necessary toenclose small groups of queries in their own transaction.Use thefollowing syntax:$dbw=wfGetDB(DB_MASTER
We use the convention $dbr for read and $dbw for write to help you keep track of whether the database object is a the world will explode Or to be a subsequent write query which succeeded on the master may fail when replicated to the slave due to a unique key collision Replication on the slave will stop and it may take hours to repair the database and get it back online Setting read_only in my cnf on the slave will avoid this but given the dire we prefer to have as many checks as possible We provide a query ( )
Use of locking reads ( e.g.the FOR UPDATE  clause)
We use the convention $dbr for read and $dbw for write to help you keep track of whether the database object is a the world will explode Or to be a subsequent write query which succeeded on the master may fail when replicated to the slave due to a unique key collision Replication on the slave will stop and it may take hours to repair the database and get it back online Setting read_only in my cnf on the slave will avoid this but given the dire we prefer to have as many checks as possible We provide a but the wrapper functions like select ( )
We use the convention $dbr for read and $dbw for write to help you keep track of whether the database object is a slave ( read-  only)
We use the convention $dbr for read and $dbw for write to help you keep track of whether the database object is a the world will explode Or to be a subsequent write query which succeeded on the master may fail when replicated to the slave due to a unique key collision Replication on the slave will stop and it may take hours to repair the database and get it back online Setting read_only in my cnf on the slave will avoid this but given the dire we prefer to have as many checks as possible We provide a but the wrapper functions like please read the documentation for tableName ( )

Variable Documentation

see documentation in includes Linker php for Linker::makeImageLink or false for current & $res = $dbr->select( )

Definition at line 21 of file database.txt.

Referenced by RedisConnRef::__call(), OutputPage::addCategoryLinks(), LinksUpdateTest::addDBDataOnce(), LinkBatch::addResultToCache(), DatabaseSqliteTest::assertResultIs(), MediaWikiTestCase::assertSelect(), MediaWiki\Auth\AuthManagerAuthPlugin::authenticate(), LinksDeletionUpdate::batchDeleteByPK(), ExternalStoreDB::batchFetchBlobs(), ExternalStoreDB::batchFetchFromURLs(), MediaWiki\Auth\AuthManager::beginAccountLink(), Database::bufferResults(), MssqlInstaller::canCreateAccounts(), MysqlInstaller::canCreateAccounts(), MssqlInstaller::catalogExists(), PostgresUpdater::changeField(), PostgresUpdater::changeFieldPurgeTable(), CheckStorage::check(), CheckStorage::checkExternalConcatBlobs(), FindOrphanedFiles::checkFiles(), CheckSyntax::checkFileWithCli(), DatabaseSqlite::checkForEnabledSearch(), NamespaceConflictChecker::checkLinkTable(), User::checkPassword(), PasswordPolicyChecks::checkPopularPasswordBlacklist(), CgzCopyTransaction::commit(), CompressOld::compressOldPages(), DatabasePostgres::constraintExists(), MediaWiki\Auth\AuthManager::continueAccountCreation(), MediaWiki\Auth\AuthManager::continueAccountLink(), MediaWiki\Auth\AuthManager::continueAuthentication(), ConvertUserOptions::convertOptionBatch(), WatchedItemStore::countVisitingWatchersMultiple(), WatchedItemStore::countWatchersMultiple(), DatabasePostgres::currentSequenceValue(), MssqlInstaller::databaseExists(), DatabaseMssql::dataSeek(), DatabasePostgres::dataSeek(), DatabaseMysqlBase::dataSeek(), DatabaseOracle::dataSeek(), DatabaseSqlite::dataSeek(), Block::defaultRetroactiveAutoblock(), PrefixSearch::defaultSearchBackend(), MemcachedClient::delete(), PostgresUpdater::describeIndex(), PostgresUpdater::describeTable(), FileBackendStore::directoryExists(), WikiExporter::do_list_authors(), JobQueueRedis::doAck(), RecompressTracked::doAllOrphans(), RecompressTracked::doAllPages(), Database::doAtomicSection(), ActiveUsersPager::doBatchLookups(), JobQueueDB::doBatchPushInternal(), CategoryViewer::doCategoryQuery(), LocalFileDeleteBatch::doDBInserts(), PopulateBacklinkNamespace::doDBUpdates(), PopulateFilearchiveSha1::doDBUpdates(), PopulateParentId::doDBUpdates(), FixExtLinksProtocolRelative::doDBUpdates(), PopulateLogUsertext::doDBUpdates(), PopulateLogSearch::doDBUpdates(), PopulateImageSha1::doDBUpdates(), DeleteOldRevisions::doDelete(), WikiPage::doDeleteArticleReal(), QueryPage::doFeed(), DBFileJournal::doGetChangeEntries(), PostgreSqlLockManager::doGetLocksOnServer(), JobQueueRedis::doGetSiblingQueueSizes(), JobQueueDB::doGetSiblingQueueSizes(), JobQueueDB::doGetSiblingQueuesWithJobs(), MysqlUpdater::doLangLinksLengthUpdate(), PopulateRevisionLength::doLenUpdates(), SpecialRecentChangesLinked::doMainQuery(), RecompressTracked::doOrphanList(), RecompressTracked::doPage(), UserCache::doQuery(), GenderCache::doQuery(), LinkBatch::doQuery(), DatabasePostgres::doQuery(), DatabaseTestHelper::doQuery(), DatabaseSqlite::doQuery(), ReassignEdits::doReassignEdits(), RefreshLinks::doRefreshLinks(), PopulateRevisionSha1::doSha1LegacyUpdates(), PopulateRevisionSha1::doSha1Updates(), FileBackendStore::doStreamFile(), MysqlUpdater::doTemplatelinksUpdate(), UpdateSearchIndex::doUpdateSearchIndex(), DatabaseSqlite::duplicateTableStructure(), DatabasePostgres::estimateRowCount(), DatabaseMssql::estimateRowCount(), DatabaseMysqlBase::estimateRowCount(), Database::estimateRowCount(), StorageTypeStats::execute(), ApiProtect::execute(), ApiCheckToken::execute(), ApiTokens::execute(), FindMissingFiles::execute(), ApiQueryMyStashedFiles::execute(), ApiWatch::execute(), ApiQueryTokens::execute(), ApiQueryExternalLinks::execute(), ApiQueryLangLinks::execute(), CheckImages::execute(), ClearInterwikiCache::execute(), ApiQueryBlocks::execute(), ApiQueryTags::execute(), ApiUnblock::execute(), ApiQueryDeletedrevs::execute(), ApiQueryIWLinks::execute(), FixUserRegistration::execute(), ApiParamInfo::execute(), ApiQueryCategoryInfo::execute(), ApiQueryFilearchive::execute(), CleanupBlocks::execute(), DeleteDefaultMessages::execute(), MigrateUserGroup::execute(), ConvertUserOptions::execute(), NukePage::execute(), RemoveUnusedAccounts::execute(), ApiBlock::execute(), CheckUsernames::execute(), DeleteArchivedFiles::execute(), DeleteOrphanedRevisions::execute(), UpdateRestrictions::execute(), WrapOldPasswords::execute(), ApiQueryLogEvents::execute(), MigrateFileRepoLayout::execute(), CleanupSpam::execute(), UploadStashCleanup::execute(), FixDoubleRedirects::execute(), ApiQueryContributions::execute(), RefreshFileHeaders::execute(), RenameDbPrefix::execute(), FixBug20757::execute(), FixTimestamps::execute(), OrphanStats::execute(), ApiQueryContributors::execute(), ApiQueryAllUsers::execute(), PurgeChangedPages::execute(), ApiAMCreateAccount::execute(), ApiLinkAccount::execute(), ApiClientLogin::execute(), UpdateDoubleWidthSearch::execute(), NukeNS::execute(), RebuildFileCache::execute(), ApiLogin::execute(), ConvertLinks::execute(), UpdateCollation::execute(), RefreshImageMetadata::execute(), ApiQueryUsers::execute(), GetConfiguration::execute(), QueryPage::execute(), LinkBatch::executeInto(), FileBackendStore::executeOpHandlesInternal(), Exif::exifGPStoNumber(), MssqlResultWrapper::fetchObject(), DatabaseMssql::fetchObject(), DatabaseMysqlBase::fetchObject(), DatabasePostgres::fetchObject(), DatabaseSqlite::fetchObject(), DatabaseOracle::fetchObject(), MssqlResultWrapper::fetchRow(), DatabaseMssql::fetchRow(), DatabasePostgres::fetchRow(), DatabaseMysqlBase::fetchRow(), DatabaseSqlite::fetchRow(), DatabaseOracle::fetchRow(), ResourceLoaderWikiModule::fetchTitleInfo(), DatabaseMssql::fieldExists(), DatabaseMysqlBase::fieldInfo(), DatabaseSqlite::fieldInfo(), DatabaseMssql::fieldInfo(), DatabaseOracle::fieldInfoMulti(), DatabaseMssql::fieldName(), DatabasePostgres::fieldName(), DatabaseMysqlBase::fieldName(), DatabaseSqlite::fieldName(), DatabaseMysqlBase::fieldType(), DatabasePostgres::fieldType(), HTMLMultiSelectField::filterDataForSubmit(), HTMLCheckMatrix::filterDataForSubmit(), LocalRepo::findBySha1(), LocalRepo::findBySha1s(), LocalRepo::findFiles(), LocalRepo::findFilesByPrefix(), TrackBlobs::findOrphanBlobs(), RecompressTracked::finishIncompleteMoves(), DoubleRedirectJob::fixRedirects(), DatabaseTestHelper::forceNextResult(), ApiParse::formatCategoryLinks(), DoubleRedirectsPage::formatResult(), GetConfiguration::formatVarDump(), RedisLockManager::freeLocksOnServer(), DatabaseMssql::freeResult(), DatabaseMysqlBase::freeResult(), DatabasePostgres::freeResult(), DatabaseSqlite::freeResult(), DatabaseOracle::freeResult(), PostgresField::fromText(), GenerateSitemap::generateNamespaces(), BatchRowUpdateTest::genSelectResult(), JobQueue::getAbandonedCount(), JobQueue::getAcquiredCount(), MediaWiki\Interwiki\ClassicInterwikiLookup::getAllPrefixesDB(), JobQueueAggregator::getAllReadyWikiQueues(), Title::getAuthorsBetween(), ContentHandler::getAutoDeleteReason(), FileBackendDBRepoWrapper::getBackendPaths(), Title::getBrokenLinksFrom(), Database::getCacheSetOptions(), BacklinkCache::getCascadeProtectedLinks(), Title::getCascadeProtectionSources(), WikiPage::getCategories(), DatabaseSqliteTest::getColumns(), SiteConfiguration::getConfig(), WikiPage::getContributors(), DatabasePostgres::getCurrentSchema(), AllMessagesTablePager::getCustomisedStatuses(), JobQueue::getDelayedCount(), ForeignDBFile::getDescriptionText(), File::getDescriptionText(), ApiQueryInfo::getDisplayTitle(), MysqlInstaller::getEngines(), LinksUpdate::getExistingCategories(), LinksUpdate::getExistingExternals(), LinksUpdate::getExistingImages(), LinksUpdate::getExistingInterlangs(), LinksUpdate::getExistingInterwikis(), LinksUpdate::getExistingLinks(), LinksUpdate::getExistingProperties(), LinksUpdate::getExistingTemplates(), WikiFilePage::getForeignCategories(), Benchmarker::getFormattedResults(), User::getFormerGroups(), SpecialBotPasswords::getFormFields(), UserRightsProxy::getGroups(), LocalFileDeleteBatch::getHashes(), DatabaseMysqlBase::getHeartbeatData(), WikiPage::getHiddenCategories(), LocalFile::getHistory(), DatabaseSqliteTest::getIndexes(), DatabaseMysqlBase::getLagFromSlaveStatus(), Title::getLinksFrom(), Title::getLinksTo(), RedisLockManager::getLocksOnServer(), DatabaseMysqlBase::getMasterPos(), DatabaseMysqlBase::getMasterServerInfo(), SpecialRandomInCategory::getMinAndMaxForCat(), SqlBagOStuff::getMulti(), BagOStuff::getMulti(), DatabaseMysqlBase::getMysqlStatus(), WatchedItemStore::getNotificationTimestampsBatch(), SpecialExport::getPagesFromCategory(), SpecialExport::getPagesFromNamespace(), Title::getParentCategories(), Revision::getParentLengths(), ApiQueryInfo::getProtectionInfo(), Title::getRedirectsHere(), ApiPageSet::getRedirectTargets(), DatabaseMysqlBase::getReplicaPos(), FixBug20757::getRevTextMap(), MWGrants::getRightsByGrant(), Linker::getRollbackEditCount(), DatabasePostgres::getSchemas(), JpegHandler::getScriptParams(), DatabasePostgres::getSearchPath(), JobQueue::getSize(), Title::getTitleProtection(), ApiQueryInfo::getTSIDs(), PasswordReset::getUsersByEmail(), WatchedItemQueryService::getWatchedItemsForUser(), WatchedItemStore::getWatchedItemsForUser(), WatchedItemQueryService::getWatchedItemsWithRecentChangeInfo(), LoadMonitorMySQL::getWeightScale(), DatabasePostgres::hasConstraint(), Database::ignoreErrors(), ImagePage::imageLinks(), LoginForm::incLoginThrottle(), DatabasePostgres::indexAttributes(), DatabaseOracle::indexExists(), DatabasePostgres::indexInfo(), DatabaseSqlite::indexInfo(), DatabaseMssql::indexInfo(), DatabaseMysqlBase::indexInfo(), DatabasePostgres::indexUnique(), ApiPageSet::initFromPageIds(), ApiPageSet::initFromQueryResult(), ApiPageSet::initFromRevIDs(), ApiPageSet::initFromTitles(), DatabaseMssql::insert(), DatabasePostgres::insert(), Database::insertSelect(), SqliteMaintenance::integrityCheck(), JobQueue::isEmpty(), PostgresInstaller::isRoleMember(), BitmapMetadataHandler::Jpeg(), UploadStash::listFiles(), DatabaseMysqlBase::listViews(), MessageCache::loadFromDB(), User::loadGroups(), User::loadOptions(), DBSiteStore::loadSites(), DatabasePostgres::lock(), MssqlInstaller::loginExists(), LocalIdLookup::lookupCentralIds(), LocalIdLookup::lookupUserNames(), RedisConnRef::luaEval(), GenerateSitemap::main(), Linker::makeImageLink(), JpegHandler::makeParamString(), BitmapHandler::makeParamString(), BenchWikimediaBaseConvert::makeRandomNumber(), DatabaseMysqlBase::masterPosWait(), MagicWordArray::matchAndRemove(), ExternalStoreDB::mergeBatchResult(), MovePage::move(), moveToExternal(), DatabaseMysql::mysqlDataSeek(), DatabaseMysqli::mysqlDataSeek(), DatabaseMysql::mysqlFetchArray(), DatabaseMysqli::mysqlFetchArray(), DatabaseMysql::mysqlFetchField(), DatabaseMysqli::mysqlFetchField(), DatabaseMysql::mysqlFetchObject(), DatabaseMysqli::mysqlFetchObject(), DatabaseMysql::mysqlFieldName(), DatabaseMysqli::mysqlFieldName(), DatabaseMysql::mysqlFieldType(), DatabaseMysqli::mysqlFieldType(), DatabaseMysql::mysqlFreeResult(), DatabaseMysqli::mysqlFreeResult(), DatabaseMysql::mysqlNumFields(), DatabaseMysqli::mysqlNumFields(), DatabaseMysql::mysqlNumRows(), DatabaseMysqli::mysqlNumRows(), DatabasePostgres::nativeInsertSelect(), Block::newFromID(), UserArray::newFromIDs(), Title::newFromIDs(), UserArray::newFromNames(), UserArray::newFromResult(), TitleArray::newFromResult(), TitleArray::newFromResult_internal(), UserArray::newFromResult_internal(), Block::newLoad(), BatchRowIterator::next(), DatabaseOracle::nextSequenceValue(), DatabasePostgres::nextSequenceValue(), FileOp::normalizeIfValidStoragePath(), LockManager::normalizePathsByType(), EditPage::noSuchSectionPage(), DatabaseMssql::numFields(), DatabasePostgres::numFields(), DatabaseMysqlBase::numFields(), DatabaseSqlite::numFields(), DatabaseOracle::numFields(), DatabaseMssql::numRows(), DatabasePostgres::numRows(), DatabaseMysqlBase::numRows(), DatabaseSqlite::numRows(), DatabaseOracle::numRows(), SpecialUnlockdb::onSubmit(), SkinTemplate::outputPage(), ImageQueryPage::outputResults(), MediaStatisticsPage::outputResults(), QueryPage::outputResults(), MessageCache::parse(), JpegHandler::parseParamString(), BacklinkCache::partition(), BacklinkCache::partitionResult(), DatabaseMssql::populateColumnCaches(), RebuildTextIndex::populateSearchIndex(), WANObjectCache::prefixCacheKeys(), ResourceLoader::preloadModuleInfo(), PageQueryPage::preprocessResults(), WantedQueryPage::preprocessResults(), WantedCategoriesPage::preprocessResults(), MostlinkedCategoriesPage::preprocessResults(), MostcategoriesPage::preprocessResults(), ShortPagesPage::preprocessResults(), ListDuplicatedFilesPage::preprocessResults(), MostinterwikisPage::preprocessResults(), ListredirectsPage::preprocessResults(), MostlinkedPage::preprocessResults(), MostlinkedTemplatesPage::preprocessResults(), BrokenRedirectsPage::preprocessResults(), DoubleRedirectsPage::preprocessResults(), LinkSearchPage::preprocessResults(), MediaStatisticsPage::preprocessResults(), MysqlInstaller::preUpgrade(), Block::prevents(), JobQueueAggregator::purge(), PurgeChangedFiles::purgeFromArchiveTable(), PurgeChangedFiles::purgeFromLogType(), PurgeList::purgeNamespace(), Maintenance::purgeRedundantText(), Database::query(), SpecialPagesWithProp::queryExistingProps(), BacklinkCache::queryLinks(), ResourceLoaderImage::rasterize(), QueryPage::reallyDoQuery(), RebuildRecentchanges::rebuildRecentChangesTablePass1(), RebuildRecentchanges::rebuildRecentChangesTablePass2(), RebuildRecentchanges::rebuildRecentChangesTablePass3(), RebuildRecentchanges::rebuildRecentChangesTablePass4(), RebuildRecentchanges::rebuildRecentChangesTablePass5(), QueryPage::recache(), JobQueueDB::recycleAndDeleteStaleJobs(), DatabasePostgres::relationExists(), MagicWord::replace(), LinkHolderArray::replaceInternal(), DbTestPreviewer::report(), ApiPageSet::resolvePendingRedirects(), resolveStubs(), ApiQueryDeletedRevisions::run(), ApiQueryAllRevisions::run(), ApiQueryAllDeletedRevisions::run(), CategoryMembershipChangeJob::run(), ApiQueryImages::run(), ApiQueryLangBacklinks::run(), ApiQueryProtectedTitles::run(), ApiQueryIWBacklinks::run(), ApiQueryExtLinksUsage::run(), ApiQueryCategories::run(), ApiQueryAllCategories::run(), ApiQueryQueryPage::run(), ApiQueryCategoryMembers::run(), ApiQueryAllPages::run(), ApiQueryLinks::run(), ApiQueryAllImages::run(), ApiQueryRevisions::run(), ApiQueryBacklinksprop::run(), ApiQueryAllLinks::run(), ApiQueryRecentChanges::run(), MemcachedClient::run_command(), ApiQueryBacklinks::runFirstQuery(), TitlePermissionTest::runGroupPermissions(), ApiQueryRandom::runQuery(), ApiQueryBacklinks::runSecondQuery(), TableCleanup::runTable(), User::saveOptions(), CategoryFinder::scanNextLayer(), MssqlInstaller::schemaExists(), EraseArchivedFile::scrubAllVersions(), UserNamePrefixSearch::search(), ApiOpenSearch::search(), SearchPostgres::searchQuery(), MssqlResultWrapper::seek(), ApiQueryBase::select(), Database::selectField(), Database::selectFieldValues(), RandomPage::selectRandomPageFromDB(), SpecialRandomInCategory::selectRandomPageFromDB(), Database::selectRow(), Database::selectRowCount(), DatabaseMysqlBase::serverIsReadOnly(), BagOStuff::setMulti(), SpecialAllPages::showChunk(), SpecialPrefixindex::showPrefixChunk(), DatabaseOracle::sourceStream(), Database::sourceStream(), MwSql::sqlDoQuery(), MwSql::sqlPrintResult(), Installer::subscribeToMediaWikiAnnounce(), MagicWord::substituteCallback(), DatabaseMssql::tableExists(), DatabaseOracle::tableExists(), Database::tableExists(), ChangeTags::tagUsageStatistics(), MediaWiki\Auth\AbstractPreAuthenticationProviderTest::testAbstractPreAuthenticationProvider(), MediaWiki\Auth\AbstractPrimaryAuthenticationProviderTest::testAbstractPrimaryAuthenticationProvider(), MediaWiki\Auth\AbstractSecondaryAuthenticationProviderTest::testAbstractSecondaryAuthenticationProvider(), MediaWiki\Auth\TemporaryPasswordPrimaryAuthenticationProviderTest::testAccountCreationEmail(), MediaWiki\Auth\ConfirmLinkSecondaryAuthenticationProviderTest::testBeginLinkAttempt(), JpegMetadataExtractorTest::testBinaryCommentStripped(), DatabaseSqliteTest::testCaseInsensitiveLike(), RevisionStorageTest::testConstructFromRow(), MediaWiki\Auth\AuthenticationResponseTest::testConstructors(), MediaWiki\Auth\ConfirmLinkSecondaryAuthenticationProviderTest::testContinueLinkAttempt(), ExifBitmapTest::testConvertMetadataLatest(), ExifBitmapTest::testConvertMetadataSoftware(), ExifBitmapTest::testConvertMetadataSoftwareNormal(), ExifBitmapTest::testConvertMetadataToOld(), BlockTest::testCrappyCrossWikiBlocks(), MediaWiki\Auth\AuthManagerTest::testCreateFromLogin(), DatabaseSqliteTest::testDeleteJoin(), WikiPageTest::testDoDeleteArticle(), WikiPageTest::testDoDeleteUpdates(), WikiPageTest::testDoEdit(), WikiPageTest::testDoEditContent(), MediaWiki\Logger\Monolog\AvroFormatterTest::testDoesSomethingWhenSchemaAvailable(), LanguageTrTest::testDottedAndDotlessI(), JpegMetadataExtractorTest::testExifByteOrder(), FileBackendTest::testExtensionFromPath(), RevisionStorageTest::testFetchRevision(), SvgTest::testGetIndependentMetaArray(), JpegTest::testGetIndependentMetaArray(), ExifBitmapTest::testGoodMetadata(), JpegTest::testInvalidFile(), PNGHandlerTest::testInvalidFile(), GIFHandlerTest::testInvalidFile(), TiffTest::testInvalidFile(), JpegMetadataExtractorTest::testIPTCHashComparisionBadHash(), JpegMetadataExtractorTest::testIPTCHashComparisionGoodHash(), JpegMetadataExtractorTest::testIPTCHashComparisionNoHash(), IPTCTest::testIPTCParseForcedUTFButInvalid(), IPTCTest::testIPTCParseMulti(), IPTCTest::testIPTCParseNoCharset88591(), IPTCTest::testIPTCParseNoCharset88591b(), IPTCTest::testIPTCParseNoCharsetUTF8(), IPTCTest::testIPTCParseUTF8(), ExifBitmapTest::testIsBrokenFile(), ExifBitmapTest::testIsInvalid(), JpegMetadataExtractorTest::testIso88591Comment(), ExifBitmapTest::testIsOldBroken(), ExifBitmapTest::testIsOldGood(), JpegTest::testJpegMetadataExtraction(), MediaWiki\Session\SessionProviderTest::testMergeMetadata(), JpegMetadataExtractorTest::testMultipleComment(), RevisionStorageTest::testNewFromArchiveRow(), RevisionStorageTest::testNewFromRow(), FileBackendTest::testNormalizeStoragePath(), DatabaseSqliteTest::testNumFields(), ExifBitmapTest::testPagedTiffHandledGracefully(), FileBackendTest::testParentStoragePath(), JpegMetadataExtractorTest::testPSIRExtraction(), TitlePermissionTest::testQuickPermissions(), IPTCTest::testRecognizeUtf8(), MediaWiki\Logger\Monolog\AvroFormatterTest::testSchemaNotAvailableReturnValue(), FileBackendTest::testSplitStoragePath(), LanguageTest::testSprintfDateNoZone(), DatabaseTest::testStoredFunctions(), BitmapMetadataHandlerTest::testTiffByteOrder(), TiffTest::testTiffMetadataExtraction(), MediaWiki\Auth\ResetPasswordSecondaryAuthenticationProviderTest::testTryReset(), DatabaseTest::testUnknownTableCorruptsResults(), JpegMetadataExtractorTest::testUtf8Comment(), JpegMetadataExtractorTest::testXMPExtraction(), JpegMetadataExtractorTest::testXMPExtractionAltAppId(), DatabaseMssql::textFieldSize(), DatabasePostgres::textFieldSize(), Database::textFieldSize(), MemcachedClient::touch(), TrackBlobs::trackOrphanText(), TrackBlobs::trackRevisions(), DatabasePostgres::triggerExists(), HTMLForm::trySubmit(), Preferences::tryUISubmit(), RecentChangesUpdateJob::updateActiveUsers(), MysqlInstaller::userDefinitelyExists(), MssqlInstaller::userExists(), Revision::userWasLastToEdit(), XMPValidate::validateDate(), UploadFromChunks::verifyChunk(), PoolCounterRedis::waitForSlotOrNotif(), and ApiWatch::watchTitle().

We use the convention $dbr for read and $dbw for write to help you keep track of whether the database object is a the world will explode Or to be a subsequent write query which succeeded on the master may fail when replicated to the slave due to a unique key collision Replication on the slave will stop and it may take hours to repair the database and get it back online Setting read_only in my cnf on the slave will avoid this but given the dire consequences

Definition at line 34 of file database.txt.

Some information about database access in MediaWiki By Tim January Database layout For information about the MediaWiki database layout

Definition at line 2 of file database.txt.

For a write use something like

Definition at line 26 of file database.txt.

We use the convention $dbr for read and $dbw for write to help you keep track of whether the database object is a the world will explode Or to be precise

Definition at line 34 of file database.txt.

Use of locking combine your existence checks into your write queries

Definition at line 165 of file database.txt.

We use the convention $dbr for read and $dbw for write to help you keep track of whether the database object is a the world will explode Or to be a subsequent write query which succeeded on the master may fail when replicated to the slave due to a unique key collision Replication on the slave will stop and it may take hours to repair the database and get it back online Setting read_only in my cnf on the slave will avoid this scenario

Definition at line 34 of file database.txt.

Some information about database access in MediaWiki By Tim January Database layout For information about the MediaWiki database such as a description of the tables and their please see
Some information about database access in MediaWiki By Tim Starling

Definition at line 2 of file database.txt.

Some information about database access in MediaWiki By Tim January Database layout For information about the MediaWiki database such as a description of the tables and their please something like this usually suffices

Definition at line 2 of file database.txt.