MediaWiki  REL1_31
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
 
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 isslave (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

◆ begin()

◆ commit()

$dbw commit ( __METHOD__  )

◆ foreach()

foreach (   $res as)

Definition at line 22 of file database.txt.

◆ insert()

$dbw insert ( )

Definition at line 2091 of file hooks.txt.

Referenced by Wikimedia\Rdbms\DatabaseSqlite::insert().

◆ is()

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

◆ reads()

Use of locking reads ( e.g. the FOR UPDATE  clause)

◆ 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 we prefer to have as many checks as possible We provide a but the wrapper functions like select ( )

◆ slave()

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)

◆ tableName()

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

◆ $res

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(), UploadChunkVerificationException::__construct(), MigrateActors::addActorsForRows(), OutputPage::addCategoryLinks(), OutputPage::addCategoryLinksToLBAndGetResult(), LinksUpdateTest::addDBDataOnce(), Benchmarker::addResult(), LinkBatch::addResultToCache(), ApiParseTest::assertParsedTo(), ApiParseTest::assertParsedToRegExp(), DatabaseSqliteTest::assertResultIs(), MediaWikiTestCase::assertSelect(), MediaWiki\Auth\AuthManagerAuthPlugin::authenticate(), LinksDeletionUpdate::batchDeleteByPK(), ExternalStoreDB::batchFetchBlobs(), ExternalStoreDB::batchFetchFromURLs(), MediaWiki\Auth\AuthManager::beginAccountLink(), Wikimedia\Rdbms\Database::bufferResults(), MssqlInstaller::canCreateAccounts(), MysqlInstaller::canCreateAccounts(), MssqlInstaller::catalogExists(), PostgresUpdater::changeField(), PostgresUpdater::changeFieldPurgeTable(), CheckStorage::check(), XmlTypeCheck::checkDTDIsSafe(), CheckStorage::checkExternalConcatBlobs(), FindOrphanedFiles::checkFiles(), Wikimedia\Rdbms\DatabaseSqlite::checkForEnabledSearch(), NamespaceConflictChecker::checkLinkTable(), User::checkPassword(), PasswordPolicyChecks::checkPopularPasswordBlacklist(), CleanupUsersWithNoId::cleanup(), CleanupInvalidDbKeys::cleanupTable(), CgzCopyTransaction::commit(), CompressOld::compressOldPages(), Wikimedia\Rdbms\DatabasePostgres::constraintExists(), MediaWiki\Auth\AuthManager::continueAccountCreation(), MediaWiki\Auth\AuthManager::continueAccountLink(), MediaWiki\Auth\AuthManager::continueAuthentication(), ConvertUserOptions::convertOptionBatch(), WatchedItemStore::countVisitingWatchersMultiple(), WatchedItemStore::countWatchersMultiple(), Wikimedia\Rdbms\DatabasePostgres::currentSequenceValue(), MssqlInstaller::databaseExists(), DatabaseOracle::dataSeek(), Wikimedia\Rdbms\DatabaseMssql::dataSeek(), Wikimedia\Rdbms\DatabaseMysqlBase::dataSeek(), Wikimedia\Rdbms\DatabasePostgres::dataSeek(), Wikimedia\Rdbms\DatabaseSqlite::dataSeek(), Block::defaultRetroactiveAutoblock(), PrefixSearch::defaultSearchBackend(), MemcachedClient::delete(), CleanupPreferences::deleteByWhere(), PostgresUpdater::describeIndex(), PostgresUpdater::describeTable(), FileBackendStore::directoryExists(), WikiExporter::do_list_authors(), JobQueueRedis::doAck(), RecompressTracked::doAllOrphans(), RecompressTracked::doAllPages(), ApiParseTest::doAssertParsedTo(), Wikimedia\Rdbms\Database::doAtomicSection(), ActiveUsersPager::doBatchLookups(), JobQueueDB::doBatchPushInternal(), CategoryViewer::doCategoryQuery(), LocalFileDeleteBatch::doDBInserts(), FixExtLinksProtocolRelative::doDBUpdates(), MigrateArchiveText::doDBUpdates(), PopulateBacklinkNamespace::doDBUpdates(), PopulateFilearchiveSha1::doDBUpdates(), PopulateImageSha1::doDBUpdates(), PopulateLogSearch::doDBUpdates(), PopulateLogUsertext::doDBUpdates(), PopulateParentId::doDBUpdates(), PopulatePPSortKey::doDBUpdates(), DeleteOldRevisions::doDelete(), WikiPage::doDeleteArticleReal(), MysqlUpdater::doExtendCommentLengths(), QueryPage::doFeed(), DBFileJournal::doGetChangeEntries(), PostgreSqlLockManager::doGetLocksOnServer(), JobQueueDB::doGetSiblingQueueSizes(), JobQueueRedis::doGetSiblingQueueSizes(), JobQueueDB::doGetSiblingQueuesWithJobs(), MysqlUpdater::doLangLinksLengthUpdate(), PopulateRevisionLength::doLenUpdates(), SpecialRecentChangesLinked::doMainQuery(), RecompressTracked::doOrphanList(), RecompressTracked::doPage(), Wikimedia\Rdbms\DatabasePostgres::doQuery(), Wikimedia\Rdbms\DatabaseSqlite::doQuery(), DatabaseTestHelper::doQuery(), GenderCache::doQuery(), LinkBatch::doQuery(), UserCache::doQuery(), ReassignEdits::doReassignEdits(), RefreshLinks::doRefreshLinks(), PopulateRevisionSha1::doSha1LegacyUpdates(), PopulateRevisionSha1::doSha1Updates(), FileBackendStore::doStreamFile(), ApiUserrightsTest::doSuccessfulRightsChange(), MysqlUpdater::doTemplatelinksUpdate(), ApiParseTest::doTestLangLinks(), UpdateSearchIndex::doUpdateSearchIndex(), RecountCategories::doWork(), Wikimedia\Rdbms\DatabasePostgres::duplicateTableStructure(), Wikimedia\Rdbms\DatabaseSqlite::duplicateTableStructure(), Wikimedia\Rdbms\Database::estimateRowCount(), Wikimedia\Rdbms\DatabaseMssql::estimateRowCount(), Wikimedia\Rdbms\DatabaseMysqlBase::estimateRowCount(), Wikimedia\Rdbms\DatabasePostgres::estimateRowCount(), QueryPage::execute(), ApiAMCreateAccount::execute(), ApiBlock::execute(), ApiCheckToken::execute(), ApiClientLogin::execute(), ApiLinkAccount::execute(), ApiLogin::execute(), ApiParamInfo::execute(), ApiProtect::execute(), ApiQueryAllUsers::execute(), ApiQueryBlocks::execute(), ApiQueryCategoryInfo::execute(), ApiQueryContributors::execute(), ApiQueryDeletedrevs::execute(), ApiQueryExternalLinks::execute(), ApiQueryFilearchive::execute(), ApiQueryIWLinks::execute(), ApiQueryLangLinks::execute(), ApiQueryLogEvents::execute(), ApiQueryMyStashedFiles::execute(), ApiQueryTokens::execute(), ApiQueryContributions::execute(), ApiQueryUsers::execute(), ApiTokens::execute(), ApiUnblock::execute(), ApiWatch::execute(), MediaWiki\Shell\Command::execute(), CheckImages::execute(), CheckUsernames::execute(), CleanupBlocks::execute(), CleanupRemovedModules::execute(), CleanupSpam::execute(), UploadStashCleanup::execute(), ClearInterwikiCache::execute(), ConvertLinks::execute(), ConvertUserOptions::execute(), DeleteArchivedFiles::execute(), DeleteDefaultMessages::execute(), DeleteOrphanedRevisions::execute(), FindMissingFiles::execute(), FixDoubleRedirects::execute(), FixTimestamps::execute(), FixUserRegistration::execute(), GetConfiguration::execute(), MigrateFileRepoLayout::execute(), MigrateUserGroup::execute(), NukeNS::execute(), NukePage::execute(), PurgeChangedPages::execute(), PurgeExpiredUserrights::execute(), PurgeModuleDeps::execute(), RebuildFileCache::execute(), RefreshFileHeaders::execute(), RefreshImageMetadata::execute(), RemoveUnusedAccounts::execute(), RenameDbPrefix::execute(), BatchedQueryRunner::execute(), FixT22757::execute(), OrphanStats::execute(), StorageTypeStats::execute(), UpdateCollation::execute(), UpdateDoubleWidthSearch::execute(), UpdateRestrictions::execute(), WrapOldPasswords::execute(), LinkBatch::executeInto(), QueryPage::executeLBFromResultWrapper(), FileBackendStore::executeOpHandlesInternal(), Exif::exifGPStoNumber(), IndexPager::extractResultInfo(), DatabaseOracle::fetchObject(), Wikimedia\Rdbms\DatabaseMssql::fetchObject(), Wikimedia\Rdbms\DatabaseMysqlBase::fetchObject(), Wikimedia\Rdbms\DatabasePostgres::fetchObject(), Wikimedia\Rdbms\DatabaseSqlite::fetchObject(), Wikimedia\Rdbms\MssqlResultWrapper::fetchObject(), DatabaseOracle::fetchRow(), Wikimedia\Rdbms\DatabaseMssql::fetchRow(), Wikimedia\Rdbms\DatabaseMysqlBase::fetchRow(), Wikimedia\Rdbms\DatabasePostgres::fetchRow(), Wikimedia\Rdbms\DatabaseSqlite::fetchRow(), Wikimedia\Rdbms\MssqlResultWrapper::fetchRow(), ResourceLoaderWikiModule::fetchTitleInfo(), Wikimedia\Rdbms\DatabaseMssql::fieldExists(), Wikimedia\Rdbms\DatabaseMssql::fieldInfo(), Wikimedia\Rdbms\DatabaseMysqlBase::fieldInfo(), Wikimedia\Rdbms\DatabaseSqlite::fieldInfo(), DatabaseOracle::fieldInfoMulti(), Wikimedia\Rdbms\DatabaseMssql::fieldName(), Wikimedia\Rdbms\DatabaseMysqlBase::fieldName(), Wikimedia\Rdbms\DatabasePostgres::fieldName(), Wikimedia\Rdbms\DatabaseSqlite::fieldName(), Wikimedia\Rdbms\DatabasePostgres::fieldType(), Wikimedia\Rdbms\DatabaseMysqlBase::fieldType(), HTMLCheckMatrix::filterDataForSubmit(), HTMLMultiSelectField::filterDataForSubmit(), LocalRepo::findBySha1(), LocalRepo::findBySha1s(), LocalRepo::findFiles(), LocalRepo::findFilesByPrefix(), TrackBlobs::findOrphanBlobs(), MediaWiki\Auth\TemporaryPasswordPrimaryAuthenticationProvider::finishAccountCreation(), RecompressTracked::finishIncompleteMoves(), DoubleRedirectJob::fixRedirects(), DatabaseTestHelper::forceNextResult(), ApiAuthManagerHelper::formatAuthenticationResponse(), ApiParse::formatCategoryLinks(), ApiParamInfo::formatHelpMessages(), ApiAuthManagerHelper::formatMessage(), DoubleRedirectsPage::formatResult(), GetConfiguration::formatVarDump(), RedisLockManager::freeLocksOnServer(), DatabaseOracle::freeResult(), Wikimedia\Rdbms\DatabaseMssql::freeResult(), Wikimedia\Rdbms\DatabaseMysqlBase::freeResult(), Wikimedia\Rdbms\DatabasePostgres::freeResult(), Wikimedia\Rdbms\DatabaseSqlite::freeResult(), Wikimedia\Rdbms\PostgresField::fromText(), GenerateSitemap::generateNamespaces(), BatchRowUpdateTest::genSelectResult(), JobQueue::getAbandonedCount(), JobQueue::getAcquiredCount(), MediaWiki\Interwiki\InterwikiLookupAdapter::getAllPrefixes(), MediaWiki\Interwiki\ClassicInterwikiLookup::getAllPrefixesDB(), JobQueueAggregator::getAllReadyWikiQueues(), ContentHandler::getAutoDeleteReason(), FileBackendDBRepoWrapper::getBackendPaths(), Title::getBrokenLinksFrom(), Wikimedia\Rdbms\Database::getCacheSetOptions(), BacklinkCache::getCascadeProtectedLinks(), Title::getCascadeProtectionSources(), WikiPage::getCategories(), MediaWiki\Tests\Maintenance\CategoriesRdfTest::getCategoryLinksIterator(), DatabaseSqliteTest::getColumns(), SiteConfiguration::getConfig(), WikiPage::getContributors(), Wikimedia\Rdbms\DatabasePostgres::getCoreSchemas(), Wikimedia\Rdbms\DatabasePostgres::getCurrentSchema(), AllMessagesTablePager::getCustomisedStatuses(), JobQueue::getDelayedCount(), File::getDescriptionText(), ForeignDBFile::getDescriptionText(), ApiQueryInfo::getDisplayTitle(), MysqlInstaller::getEngines(), LinksUpdate::getExistingCategories(), LinksUpdate::getExistingExternals(), LinksUpdate::getExistingImages(), LinksUpdate::getExistingInterlangs(), LinksUpdate::getExistingInterwikis(), LinksUpdate::getExistingLinks(), LinksUpdate::getExistingProperties(), LinksUpdate::getExistingTemplates(), WikiFilePage::getForeignCategories(), User::getFormerGroups(), SpecialBotPasswords::getFormFields(), LocalFileDeleteBatch::getHashes(), Wikimedia\Rdbms\DatabaseMysqlBase::getHeartbeatData(), WikiPage::getHiddenCategories(), LocalFile::getHistory(), DatabaseSqliteTest::getIndexes(), Wikimedia\Rdbms\DatabaseMysqlBase::getLagFromSlaveStatus(), Title::getLinksFrom(), Title::getLinksTo(), RedisLockManager::getLocksOnServer(), Wikimedia\Rdbms\DatabaseMysqlBase::getMasterServerInfo(), UserGroupMembership::getMembershipsForUser(), SpecialRandomInCategory::getMinAndMaxForCat(), BagOStuff::getMulti(), SqlBagOStuff::getMulti(), Wikimedia\Rdbms\DatabaseMysqlBase::getMysqlStatus(), WatchedItemStore::getNotificationTimestampsBatch(), SpecialExport::getPagesFromCategory(), SpecialExport::getPagesFromNamespace(), Title::getParentCategories(), ApiQueryInfo::getProtectionInfo(), Title::getRedirectsHere(), ApiPageSet::getRedirectTargets(), FixT22757::getRevTextMap(), MWGrants::getRightsByGrant(), Linker::getRollbackEditCount(), Wikimedia\Rdbms\DatabasePostgres::getSchemas(), JpegHandler::getScriptParams(), Wikimedia\Rdbms\DatabasePostgres::getSearchPath(), Wikimedia\Rdbms\DatabaseMysqlBase::getServerGTIDs(), Wikimedia\Rdbms\DatabaseMysqlBase::getServerId(), Wikimedia\Rdbms\DatabaseMysqlBase::getServerUUID(), JobQueue::getSize(), WANCacheReapUpdate::getTitleChangeEvents(), Title::getTitleProtectionInternal(), BlockListPager::getTotalAutoblocks(), ApiQueryInfo::getTSIDs(), PasswordReset::getUsersByEmail(), WatchedItemQueryService::getWatchedItemsForUser(), WatchedItemStore::getWatchedItemsForUser(), WatchedItemQueryService::getWatchedItemsWithRecentChangeInfo(), Wikimedia\Rdbms\LoadMonitorMySQL::getWeightScale(), MemcachedPeclBagOStuff::getWithToken(), Wikimedia\Rdbms\DatabasePostgres::hasConstraint(), ImagePage::imageLinks(), LoginForm::incLoginThrottle(), Wikimedia\Rdbms\DatabasePostgres::indexAttributes(), DatabaseOracle::indexExists(), Wikimedia\Rdbms\DatabaseMssql::indexInfo(), Wikimedia\Rdbms\DatabaseMysqlBase::indexInfo(), Wikimedia\Rdbms\DatabasePostgres::indexInfo(), Wikimedia\Rdbms\DatabaseSqlite::indexInfo(), Wikimedia\Rdbms\DatabasePostgres::indexUnique(), ApiPageSet::initFromPageIds(), ApiPageSet::initFromQueryResult(), ApiPageSet::initFromRevIDs(), ApiPageSet::initFromTitles(), Wikimedia\Rdbms\DatabaseMssql::insert(), DatabaseOracle::insertId(), Wikimedia\Rdbms\DatabasePostgres::insertId(), SqliteMaintenance::integrityCheck(), JobQueue::isEmpty(), PostgresInstaller::isRoleMember(), BitmapMetadataHandler::Jpeg(), UploadStash::listFiles(), MediaWiki\Storage\RevisionStore::listRevisionSizes(), Wikimedia\Rdbms\DatabaseMysqlBase::listViews(), MigrateComments::loadCommentIDs(), MessageCache::loadFromDB(), User::loadOptions(), DBSiteStore::loadSites(), Wikimedia\Rdbms\DatabasePostgres::lock(), MssqlInstaller::loginExists(), LocalIdLookup::lookupCentralIds(), LocalIdLookup::lookupUserNames(), RedisConnRef::luaEval(), GenerateSitemap::main(), Linker::makeImageLink(), BitmapHandler::makeParamString(), JpegHandler::makeParamString(), BenchWikimediaBaseConvert::makeRandomNumber(), Wikimedia\Rdbms\DatabaseMysqlBase::masterPosWait(), MagicWordArray::matchAndRemove(), ExternalStoreDB::mergeBatchResult(), MigrateComments::migrate(), MigrateActors::migrate(), MigrateActors::migrateLogSearch(), MigrateActors::migrateToTemp(), MigrateComments::migrateToTemp(), MovePage::move(), moveToExternal(), Wikimedia\Rdbms\DatabaseMysqli::mysqlDataSeek(), Wikimedia\Rdbms\DatabaseMysqli::mysqlFetchArray(), Wikimedia\Rdbms\DatabaseMysqli::mysqlFetchField(), Wikimedia\Rdbms\DatabaseMysqli::mysqlFetchObject(), Wikimedia\Rdbms\DatabaseMysqli::mysqlFieldName(), Wikimedia\Rdbms\DatabaseMysqli::mysqlFieldType(), Wikimedia\Rdbms\DatabaseMysqli::mysqlFreeResult(), Wikimedia\Rdbms\DatabaseMysqli::mysqlNumFields(), Wikimedia\Rdbms\DatabaseMysqli::mysqlNumRows(), Block::newFromID(), Title::newFromIDs(), UserArray::newFromIDs(), UserArray::newFromNames(), TitleArray::newFromResult(), UserArray::newFromResult(), TitleArray::newFromResult_internal(), UserArray::newFromResult_internal(), Block::newLoad(), BatchRowIterator::next(), Wikimedia\Rdbms\Database::nonNativeInsertSelect(), FileOp::normalizeIfValidStoragePath(), LockManager::normalizePathsByType(), EditPage::noSuchSectionPage(), DatabaseOracle::numFields(), Wikimedia\Rdbms\DatabaseMssql::numFields(), Wikimedia\Rdbms\DatabaseMysqlBase::numFields(), Wikimedia\Rdbms\DatabasePostgres::numFields(), Wikimedia\Rdbms\DatabaseSqlite::numFields(), DatabaseOracle::numRows(), Wikimedia\Rdbms\DatabaseMssql::numRows(), Wikimedia\Rdbms\DatabaseMysqlBase::numRows(), Wikimedia\Rdbms\DatabasePostgres::numRows(), Wikimedia\Rdbms\DatabaseSqlite::numRows(), SpecialUnlockdb::onSubmit(), SkinTemplate::outputPage(), ImageQueryPage::outputResults(), QueryPage::outputResults(), MediaStatisticsPage::outputResults(), PurgeChangedPages::pageableSortedRows(), MessageCache::parse(), XmlTypeCheck::parseDTD(), JpegHandler::parseParamString(), BacklinkCache::partition(), BacklinkCache::partitionResult(), Wikimedia\Rdbms\DatabaseMssql::populateColumnCaches(), RebuildTextIndex::populateSearchIndex(), WANObjectCache::prefixCacheKeys(), ResourceLoader::preloadModuleInfo(), PageQueryPage::preprocessResults(), WantedQueryPage::preprocessResults(), AncientPagesPage::preprocessResults(), BrokenRedirectsPage::preprocessResults(), DoubleRedirectsPage::preprocessResults(), LinkSearchPage::preprocessResults(), ListDuplicatedFilesPage::preprocessResults(), ListredirectsPage::preprocessResults(), MIMEsearchPage::preprocessResults(), MostcategoriesPage::preprocessResults(), MostinterwikisPage::preprocessResults(), MostlinkedPage::preprocessResults(), MostlinkedCategoriesPage::preprocessResults(), MostlinkedTemplatesPage::preprocessResults(), ShortPagesPage::preprocessResults(), UnusedCategoriesPage::preprocessResults(), UnwatchedpagesPage::preprocessResults(), WantedCategoriesPage::preprocessResults(), MediaStatisticsPage::preprocessResults(), MysqlInstaller::preUpgrade(), Block::prevents(), JobQueueAggregator::purge(), UserGroupMembership::purgeExpired(), RecentChangesUpdateJob::purgeExpiredRows(), PurgeChangedFiles::purgeFromArchiveTable(), PurgeChangedFiles::purgeFromLogType(), PurgeList::purgeNamespace(), Maintenance::purgeRedundantText(), SpecialPagesWithProp::queryExistingProps(), BacklinkCache::queryLinks(), ResourceLoaderImage::rasterize(), QueryPage::reallyDoQuery(), ShortPagesPage::reallyDoQuery(), RebuildRecentchanges::rebuildRecentChangesTablePass1(), RebuildRecentchanges::rebuildRecentChangesTablePass2(), RebuildRecentchanges::rebuildRecentChangesTablePass3(), RebuildRecentchanges::rebuildRecentChangesTablePass4(), RebuildRecentchanges::rebuildRecentChangesTablePass5(), QueryPage::recache(), LocalFile::recordUpload2(), JobQueueDB::recycleAndDeleteStaleJobs(), RefreshLinks::refreshCategory(), Wikimedia\Rdbms\DatabasePostgres::relationExists(), MagicWord::replace(), LinkHolderArray::replaceInternal(), DbTestPreviewer::report(), Wikimedia\Rdbms\DatabasePostgres::resetSequenceForTable(), ApiPageSet::resolvePendingRedirects(), resolveStubs(), ApiQueryAllCategories::run(), ApiQueryAllImages::run(), ApiQueryAllLinks::run(), ApiQueryAllPages::run(), ApiQueryCategories::run(), ApiQueryCategoryMembers::run(), ApiQueryExtLinksUsage::run(), ApiQueryImages::run(), ApiQueryIWBacklinks::run(), ApiQueryLangBacklinks::run(), ApiQueryLinks::run(), ApiQueryProtectedTitles::run(), ApiQueryQueryPage::run(), ApiQueryRecentChanges::run(), CategoryMembershipChangeJob::run(), ApiQueryAllDeletedRevisions::run(), ApiQueryAllRevisions::run(), ApiQueryBacklinksprop::run(), ApiQueryDeletedRevisions::run(), ApiQueryRevisions::run(), MemcachedClient::run_command(), ApiQueryBacklinks::runFirstQuery(), TitlePermissionTest::runGroupPermissions(), ApiQueryRandom::runQuery(), ApiQueryBacklinks::runSecondQuery(), TableCleanup::runTable(), BotPassword::save(), User::saveOptions(), CategoryFinder::scanNextLayer(), MssqlInstaller::schemaExists(), EraseArchivedFile::scrubAllVersions(), UserNamePrefixSearch::search(), ApiOpenSearch::search(), SearchPostgres::searchQuery(), Wikimedia\Rdbms\MssqlResultWrapper::seek(), ApiQueryBase::select(), Wikimedia\Rdbms\Database::selectField(), Wikimedia\Rdbms\Database::selectFieldValues(), SpecialRandomInCategory::selectRandomPageFromDB(), RandomPage::selectRandomPageFromDB(), Wikimedia\Rdbms\Database::selectRow(), Wikimedia\Rdbms\Database::selectRowCount(), Wikimedia\Rdbms\DatabaseMysqlBase::serverIsReadOnly(), Wikimedia\Rdbms\DatabasePostgres::serverIsReadOnly(), BagOStuff::setMulti(), SpecialAllPages::showChunk(), SpecialPrefixindex::showPrefixChunk(), DatabaseOracle::sourceStream(), Wikimedia\Rdbms\Database::sourceStream(), MwSql::sqlDoQuery(), MwSql::sqlPrintResult(), MediaWiki\Preferences\DefaultPreferencesFactory::submitForm(), Installer::subscribeToMediaWikiAnnounce(), MagicWord::substituteCallback(), DatabaseOracle::tableExists(), Wikimedia\Rdbms\Database::tableExists(), Wikimedia\Rdbms\DatabaseMssql::tableExists(), ChangeTags::tagUsageStatistics(), MediaWiki\Auth\AbstractPreAuthenticationProviderTest::testAbstractPreAuthenticationProvider(), MediaWiki\Auth\AbstractPrimaryAuthenticationProviderTest::testAbstractPrimaryAuthenticationProvider(), MediaWiki\Auth\AbstractSecondaryAuthenticationProviderTest::testAbstractSecondaryAuthenticationProvider(), MediaWiki\Auth\TemporaryPasswordPrimaryAuthenticationProviderTest::testAccountCreationEmail(), UserTest::testAutoblockCookieInauthentic(), UserTest::testAutoblockCookieInfiniteExpiry(), UserTest::testAutoblockCookieNoSecretKey(), UserTest::testAutoblockCookies(), UserTest::testAutoblockCookiesDisabled(), MediaWiki\Auth\ConfirmLinkSecondaryAuthenticationProviderTest::testBeginLinkAttempt(), MediaWiki\Tests\Maintenance\BenchmarkerTest::testBenchName_method(), MediaWiki\Tests\Maintenance\BenchmarkerTest::testBenchName_string(), JpegMetadataExtractorTest::testBinaryCommentStripped(), UserTest::testBlockInstanceCache(), ApiBlockTest::testBlockWithEmailBlock(), ApiBlockTest::testBlockWithExpiry(), ApiBlockTest::testBlockWithHide(), DatabaseSqliteTest::testCaseInsensitiveLike(), ApiParseTest::testCategoriesHtml(), MediaWiki\Auth\AuthenticationResponseTest::testConstructors(), MediaWiki\Auth\ConfirmLinkSecondaryAuthenticationProviderTest::testContinueLinkAttempt(), ExifBitmapTest::testConvertMetadataLatest(), ExifBitmapTest::testConvertMetadataSoftware(), ExifBitmapTest::testConvertMetadataSoftwareNormal(), ExifBitmapTest::testConvertMetadataToOld(), BlockTest::testCrappyCrossWikiBlocks(), MediaWiki\Auth\AuthManagerTest::testCreateFromLogin(), DatabaseSqliteTest::testDeleteJoin(), WikiPageDbTestBase::testDoDeleteArticle(), WikiPageDbTestBase::testDoDeleteUpdates(), WikiPageDbTestBase::testDoEditContent(), MediaWiki\Logger\Monolog\AvroFormatterTest::testDoesSomethingWhenSchemaAvailable(), LanguageTrTest::testDottedAndDotlessI(), ApiEditPageTest::testEditAbortedByEditPageHookWithResult(), ApiParseTest::testEffectiveLangLinks(), JpegMetadataExtractorTest::testExifByteOrder(), ApiParseTest::testExistingSection(), FileBackendTest::testExtensionFromPath(), RevisionDbTestBase::testFetchRevision(), ApiParseTest::testFollowedRedirect(), ApiParseTest::testFollowedRedirectById(), ApiParseTest::testFormatCategories(), CommentStoreTest::testGetCommentErrors(), SVGTest::testGetIndependentMetaArray(), JpegTest::testGetIndependentMetaArray(), WatchedItemQueryServiceUnitTest::testGetWatchedItemsWithRecentChangeInfo_extension(), ExifBitmapTest::testGoodMetadata(), ApiParseTest::testHeadHtml(), ApiParseTest::testHeadItems(), ApiParseTest::testHeadItemsWithSkin(), ApiParseTest::testIndicators(), ApiParseTest::testIndicatorsWithSkin(), JpegMetadataExtractorTest::testInfiniteRead(), JpegMetadataExtractorTest::testInfiniteRead2(), RevisionDbTestBase::testInsertOn(), GIFHandlerTest::testInvalidFile(), JpegTest::testInvalidFile(), PNGHandlerTest::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(), ApiParseTest::testIwlinks(), JpegTest::testJpegMetadataExtraction(), ApiParseTest::testLimitReports(), MediaWiki\Session\SessionProviderTest::testMergeMetadata(), ApiParseTest::testModules(), ApiParseTest::testModulesWithSkin(), ApiMoveTest::testMove(), ApiMoveTest::testMoveById(), ApiMoveTest::testMoveSubpages(), ApiMoveTest::testMoveSubpagesError(), ApiMoveTest::testMoveTalk(), ApiMoveTest::testMoveTalkFailed(), JpegMetadataExtractorTest::testMultipleComment(), RevisionDbTestBase::testNewFromArchiveRow(), RevisionDbTestBase::testNewFromArchiveRowOverrides(), RevisionDbTestBase::testNewFromRow(), MediaWiki\Tests\Storage\RevisionStoreDbTest::testNewRevisionFromArchiveRow(), MediaWiki\Tests\Storage\RevisionStoreDbTest::testNewRevisionFromArchiveRow_legacyEncoding(), ApiParseTest::testNewSection(), ApiParseTest::testNoPst(), FileBackendTest::testNormalizeStoragePath(), DatabaseSqliteTest::testNumFields(), ApiParseTest::testOnlyPst(), ExifBitmapTest::testPagedTiffHandledGracefully(), FileBackendTest::testParentStoragePath(), ApiParseTest::testParseById(), ApiParseTest::testParseByName(), ApiParseTest::testParseByOldId(), ApiParseTest::testParseTree(), SearchEngineTest::testPhraseSearch(), SearchEngineTest::testPhraseSearchHighlight(), ApiMoveTest::testPingLimiter(), JpegMetadataExtractorTest::testPSIRExtraction(), ApiParseTest::testPst(), TitlePermissionTest::testQuickPermissions(), IPTCTest::testRecognizeUtf8(), ApiParseTest::testRevDel(), ApiParseTest::testRevId(), ApiParseTest::testRevidNoText(), MediaWiki\Logger\Monolog\AvroFormatterTest::testSchemaNotAvailableReturnValue(), ApiParseTest::testSection(), FileBackendTest::testSplitStoragePath(), LanguageTest::testSprintfDateNoZone(), DatabaseIntegrationTest::testStoredFunctions(), ApiParseTest::testSuppressed(), ApiMoveTest::testSuppressRedirect(), ApiMoveTest::testSuppressRedirectNoPermission(), ApiParseTest::testTextNoContentModel(), BitmapMetadataHandlerTest::testTiffByteOrder(), TiffTest::testTiffMetadataExtraction(), ApiParseTest::testTitleNoText(), ApiParseTest::testTitleProvided(), ApiParseTest::testTitleWithNonMatchingRevId(), MediaWiki\Auth\ResetPasswordSecondaryAuthenticationProviderTest::testTryReset(), PageArchiveTest::testUndeleteRevisions(), ApiParseTest::testUnfollowedRedirect(), DatabaseIntegrationTest::testUnknownTableCorruptsResults(), JpegMetadataExtractorTest::testUtf8Comment(), ApiUserrightsTest::testWebToken(), SearchEngineTest::testWildcardSearch(), JpegMetadataExtractorTest::testXMPExtraction(), JpegMetadataExtractorTest::testXMPExtractionAltAppId(), JpegMetadataExtractorTest::testXMPExtractionNullChar(), Wikimedia\Rdbms\Database::textFieldSize(), Wikimedia\Rdbms\DatabaseMssql::textFieldSize(), Wikimedia\Rdbms\DatabasePostgres::textFieldSize(), ParameterizedPassword::toString(), MemcachedClient::touch(), TrackBlobs::trackOrphanText(), TrackBlobs::trackRevisions(), Wikimedia\Rdbms\DatabasePostgres::triggerExists(), HTMLForm::trySubmit(), RecentChangesUpdateJob::updateActiveUsers(), MysqlInstaller::userDefinitelyExists(), MssqlInstaller::userExists(), MediaWiki\Storage\RevisionStore::userWasLastToEdit(), XMPValidate::validateDate(), UploadFromChunks::verifyChunk(), PoolCounterRedis::waitForSlotOrNotif(), and ApiWatch::watchTitle().

◆ consequences

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 38 of file database.txt.

◆ contents

◆ layout

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

Definition at line 8 of file database.txt.

◆ like

For a write use something like

Definition at line 26 of file database.txt.

Referenced by CleanupInvalidDbKeys::cleanupTable().

◆ precise

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.

◆ queries

Use of locking combine your existence checks into your write queries

Definition at line 165 of file database.txt.

◆ 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 but given the dire we prefer to have as many checks as possible We provide a query

◆ scenario

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 38 of file database.txt.

◆ see

◆ Starling

Some information about database access in MediaWiki By Tim Starling

Definition at line 2 of file database.txt.

◆ suffices

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 18 of file database.txt.