MediaWiki  master
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 LoadBalancer::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 LoadBalancer::getLaggedReplicaMode(). 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 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 ( )

◆ 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 ( )

◆ 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 ( )

◆ 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 MigrateActors::addActorsForRows(), OutputPage::addCategoryLinks(), OutputPage::addCategoryLinksToLBAndGetResult(), LinksUpdateTest::addDBDataOnce(), Benchmarker::addResult(), LinkBatch::addResultToCache(), WikiPage::archiveRevisions(), 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(), NamespaceDupes::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(), MediaWikiTestCase::copyTestData(), WatchedItemStore::countVisitingWatchersMultiple(), WatchedItemStore::countWatchersMultiple(), Wikimedia\Rdbms\DatabasePostgres::currentSequenceValue(), MssqlInstaller::databaseExists(), Wikimedia\Rdbms\DatabaseMssql::dataSeek(), DatabaseOracle::dataSeek(), Wikimedia\Rdbms\DatabasePostgres::dataSeek(), Wikimedia\Rdbms\DatabaseMysqlBase::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(), Wikimedia\Rdbms\Database::doAtomicSection(), ActiveUsersPager::doBatchLookups(), JobQueueDB::doBatchPushInternal(), CategoryViewer::doCategoryQuery(), LocalFileDeleteBatch::doDBInserts(), DeduplicateArchiveRevId::doDBUpdates(), PopulatePPSortKey::doDBUpdates(), PopulateFilearchiveSha1::doDBUpdates(), PopulateBacklinkNamespace::doDBUpdates(), PopulateParentId::doDBUpdates(), FixExtLinksProtocolRelative::doDBUpdates(), PopulateExternallinksIndex60::doDBUpdates(), PopulateLogUsertext::doDBUpdates(), RefreshExternallinksIndex::doDBUpdates(), MigrateImageCommentTemp::doDBUpdates(), PopulateLogSearch::doDBUpdates(), MigrateArchiveText::doDBUpdates(), PopulateImageSha1::doDBUpdates(), DeleteOldRevisions::doDelete(), MysqlUpdater::doExtendCommentLengths(), QueryPage::doFeed(), DBFileJournal::doGetChangeEntries(), PostgreSqlLockManager::doGetLocksOnServer(), JobQueueRedis::doGetSiblingQueueSizes(), JobQueueDB::doGetSiblingQueueSizes(), JobQueueDB::doGetSiblingQueuesWithJobs(), MysqlUpdater::doLangLinksLengthUpdate(), PopulateRevisionLength::doLenUpdates(), SpecialRecentChangesLinked::doMainQuery(), RecompressTracked::doOrphanList(), RecompressTracked::doPage(), ApiQuerySiteinfoTest::doQuery(), UserCache::doQuery(), GenderCache::doQuery(), LinkBatch::doQuery(), Wikimedia\Rdbms\DatabasePostgres::doQuery(), DatabaseTestHelper::doQuery(), Wikimedia\Rdbms\DatabaseSqlite::doQuery(), ReassignEdits::doReassignEdits(), RefreshLinks::doRefreshLinks(), PopulateRevisionSha1::doSha1LegacyUpdates(), PopulateRevisionSha1::doSha1Updates(), ApiStashEditTest::doStash(), FileBackendStore::doStreamFile(), ApiUserrightsTest::doSuccessfulRightsChange(), MysqlUpdater::doTemplatelinksUpdate(), ApiParseTest::doTestLangLinks(), UpdateSearchIndex::doUpdateSearchIndex(), RecountCategories::doWork(), Wikimedia\Rdbms\DatabasePostgres::duplicateTableStructure(), Wikimedia\Rdbms\DatabaseSqlite::duplicateTableStructure(), Wikimedia\Rdbms\DatabasePostgres::estimateRowCount(), Wikimedia\Rdbms\DatabaseMssql::estimateRowCount(), Wikimedia\Rdbms\DatabaseMysqlBase::estimateRowCount(), Wikimedia\Rdbms\Database::estimateRowCount(), StorageTypeStats::execute(), ApiProtect::execute(), ApiTokens::execute(), ApiCheckToken::execute(), ApiWatch::execute(), ApiQueryExternalLinks::execute(), FindMissingFiles::execute(), ApiQueryTokens::execute(), ApiUnblock::execute(), ApiParamInfo::execute(), ApiQueryMyStashedFiles::execute(), ApiQueryCategoryInfo::execute(), ApiQueryLangLinks::execute(), ApiQueryIWLinks::execute(), ApiQueryBlocks::execute(), PurgeExpiredUserrights::execute(), ApiBlock::execute(), ApiQueryDeletedrevs::execute(), CheckImages::execute(), ClearInterwikiCache::execute(), FixUserRegistration::execute(), ApiQueryFilearchive::execute(), CleanupBlocks::execute(), MigrateUserGroup::execute(), DeleteArchivedFiles::execute(), DeleteDefaultMessages::execute(), NukePage::execute(), RemoveUnusedAccounts::execute(), CheckUsernames::execute(), PurgeModuleDeps::execute(), UpdateRestrictions::execute(), ApiQueryAllUsers::execute(), MigrateFileRepoLayout::execute(), ApiQueryLogEvents::execute(), CleanupUploadStash::execute(), CleanupSpam::execute(), ConvertUserOptions::execute(), DeleteOrphanedRevisions::execute(), FixDoubleRedirects::execute(), ApiQueryUserContribs::execute(), RenameDbPrefix::execute(), FixT22757::execute(), WrapOldPasswords::execute(), CleanupRemovedModules::execute(), FixTimestamps::execute(), ApiQueryContributors::execute(), ResetPageRandom::execute(), OrphanStats::execute(), RunBatchedQuery::execute(), ApiAMCreateAccount::execute(), ApiLinkAccount::execute(), ApiClientLogin::execute(), PurgeChangedPages::execute(), UpdateDoubleWidthSearch::execute(), RefreshFileHeaders::execute(), NukeNS::execute(), RebuildFileCache::execute(), ConvertLinks::execute(), UpdateCollation::execute(), ApiLogin::execute(), ApiQueryUsers::execute(), RefreshImageMetadata::execute(), GetConfiguration::execute(), MediaWiki\Shell\Command::execute(), QueryPage::execute(), LinkBatch::executeInto(), FileBackendStore::executeOpHandlesInternal(), Exif::exifGPStoNumber(), Wikimedia\Rdbms\MssqlResultWrapper::fetchObject(), Wikimedia\Rdbms\DatabaseMssql::fetchObject(), DatabaseOracle::fetchObject(), Wikimedia\Rdbms\DatabasePostgres::fetchObject(), Wikimedia\Rdbms\DatabaseMysqlBase::fetchObject(), Wikimedia\Rdbms\DatabaseSqlite::fetchObject(), Wikimedia\Rdbms\MssqlResultWrapper::fetchRow(), Wikimedia\Rdbms\DatabaseMssql::fetchRow(), DatabaseOracle::fetchRow(), Wikimedia\Rdbms\DatabasePostgres::fetchRow(), Wikimedia\Rdbms\DatabaseMysqlBase::fetchRow(), Wikimedia\Rdbms\DatabaseSqlite::fetchRow(), ResourceLoaderWikiModule::fetchTitleInfo(), Wikimedia\Rdbms\DatabaseMssql::fieldExists(), Wikimedia\Rdbms\DatabaseMysqlBase::fieldInfo(), Wikimedia\Rdbms\DatabaseSqlite::fieldInfo(), Wikimedia\Rdbms\DatabaseMssql::fieldInfo(), DatabaseOracle::fieldInfoMulti(), Wikimedia\Rdbms\DatabaseMssql::fieldName(), Wikimedia\Rdbms\DatabasePostgres::fieldName(), Wikimedia\Rdbms\DatabaseMysqlBase::fieldName(), Wikimedia\Rdbms\DatabaseSqlite::fieldName(), Wikimedia\Rdbms\DatabaseMysqlBase::fieldType(), Wikimedia\Rdbms\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(), Wikimedia\Rdbms\DatabaseMssql::freeResult(), Wikimedia\Rdbms\DatabaseMysqlBase::freeResult(), DatabaseOracle::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(), CategoryChangesRdfTest::getCategoryLinksIterator(), DatabaseSqliteTest::getColumns(), SiteConfiguration::getConfig(), WikiPage::getContributors(), Wikimedia\Rdbms\DatabasePostgres::getCoreSchemas(), Wikimedia\Rdbms\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(), 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(), SqlBagOStuff::getMulti(), BagOStuff::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(), Wikimedia\Rdbms\DatabasePostgres::indexAttributes(), DatabaseOracle::indexExists(), Wikimedia\Rdbms\DatabasePostgres::indexInfo(), Wikimedia\Rdbms\DatabaseSqlite::indexInfo(), Wikimedia\Rdbms\DatabaseMssql::indexInfo(), Wikimedia\Rdbms\DatabaseMysqlBase::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(), Revision\RevisionStore::listRevisionSizes(), Wikimedia\Rdbms\DatabaseMysqlBase::listViews(), MigrateComments::loadCommentIDs(), PopulateContentTables::loadContentMap(), MessageCache::loadFromDB(), User::loadOptions(), DBSiteStore::loadSites(), Revision\RevisionStore::loadSlotRecords(), 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(), MigrateComments::migrateToTemp(), MigrateActors::migrateToTemp(), MovePage::move(), moveToExternal(), MWException::msg(), MWExceptionRenderer::msg(), 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(), UserArray::newFromIDs(), Title::newFromIDs(), UserArray::newFromNames(), UserArray::newFromResult(), TitleArray::newFromResult(), TitleArray::newFromResult_internal(), UserArray::newFromResult_internal(), Block::newLoad(), BatchRowIterator::next(), Wikimedia\Rdbms\Database::nonNativeInsertSelect(), FileOp::normalizeIfValidStoragePath(), LockManager::normalizePathsByType(), EditPage::noSuchSectionPage(), Wikimedia\Rdbms\DatabaseMssql::numFields(), DatabaseOracle::numFields(), Wikimedia\Rdbms\DatabasePostgres::numFields(), Wikimedia\Rdbms\DatabaseMysqlBase::numFields(), Wikimedia\Rdbms\DatabaseSqlite::numFields(), Wikimedia\Rdbms\DatabaseMssql::numRows(), DatabaseOracle::numRows(), Wikimedia\Rdbms\DatabasePostgres::numRows(), Wikimedia\Rdbms\DatabaseMysqlBase::numRows(), Wikimedia\Rdbms\DatabaseSqlite::numRows(), SpecialUnlockdb::onSubmit(), SkinTemplate::outputPage(), ImageQueryPage::outputResults(), MediaStatisticsPage::outputResults(), QueryPage::outputResults(), SearchEnginePrefixTest::paginationProvider(), MessageCache::parse(), XmlTypeCheck::parseDTD(), JpegHandler::parseParamString(), BacklinkCache::partition(), BacklinkCache::partitionResult(), Wikimedia\Rdbms\DatabaseMssql::populateColumnCaches(), PopulateContentTables::populateContentTablesForRowBatch(), RebuildTextIndex::populateSearchIndex(), WANObjectCache::prefixCacheKeys(), ResourceLoader::preloadModuleInfo(), PageQueryPage::preprocessResults(), WantedQueryPage::preprocessResults(), UnwatchedpagesPage::preprocessResults(), WantedCategoriesPage::preprocessResults(), MostlinkedCategoriesPage::preprocessResults(), MostcategoriesPage::preprocessResults(), MostinterwikisPage::preprocessResults(), ListDuplicatedFilesPage::preprocessResults(), ListredirectsPage::preprocessResults(), AncientPagesPage::preprocessResults(), MostlinkedPage::preprocessResults(), MostlinkedTemplatesPage::preprocessResults(), UnusedCategoriesPage::preprocessResults(), ShortPagesPage::preprocessResults(), BrokenRedirectsPage::preprocessResults(), DoubleRedirectsPage::preprocessResults(), LinkSearchPage::preprocessResults(), MIMEsearchPage::preprocessResults(), MediaStatisticsPage::preprocessResults(), MysqlInstaller::preUpgrade(), Block::prevents(), DeduplicateArchiveRevId::processArRevIds(), JobQueueAggregator::purge(), UserGroupMembership::purgeExpired(), RecentChangesUpdateJob::purgeExpiredRows(), PurgeChangedFiles::purgeFromArchiveTable(), PurgeChangedFiles::purgeFromLogType(), PurgeList::purgeNamespace(), Maintenance::purgeRedundantText(), SpecialPagesWithProp::queryExistingProps(), BacklinkCache::queryLinks(), ResourceLoaderImage::rasterize(), ShortPagesPage::reallyDoQuery(), QueryPage::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(), ApiQueryDeletedRevisions::run(), ApiQueryAllRevisions::run(), ApiQueryAllDeletedRevisions::run(), ApiQueryImages::run(), ApiQueryProtectedTitles::run(), ApiQueryExtLinksUsage::run(), ApiQueryLangBacklinks::run(), ApiQueryIWBacklinks::run(), ApiQueryCategories::run(), ApiQueryAllCategories::run(), ApiQueryQueryPage::run(), ApiQueryAllPages::run(), ApiQueryCategoryMembers::run(), ApiQueryLinks::run(), ApiQueryAllImages::run(), CategoryMembershipChangeJob::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(), Wikimedia\Rdbms\MssqlResultWrapper::seek(), ApiQueryBase::select(), Wikimedia\Rdbms\Database::selectField(), Wikimedia\Rdbms\Database::selectFieldValues(), RandomPage::selectRandomPageFromDB(), SpecialRandomInCategory::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(), Wikimedia\Rdbms\DatabaseSqlite::tableExists(), DatabaseOracle::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(), ApiQuerySiteinfoTest::testContinuation(), MediaWiki\Auth\ConfirmLinkSecondaryAuthenticationProviderTest::testContinueLinkAttempt(), ExifBitmapTest::testConvertMetadataLatest(), ExifBitmapTest::testConvertMetadataSoftware(), ExifBitmapTest::testConvertMetadataSoftwareNormal(), ExifBitmapTest::testConvertMetadataToOld(), BlockTest::testCrappyCrossWikiBlocks(), MediaWiki\Auth\AuthManagerTest::testCreateFromLogin(), ContentSecurityPolicyTest::testCSPIsEnabled(), DatabaseSqliteTest::testDeleteJoin(), ChangeTagsTest::testDeleteTags(), WikiPageDbTestBase::testDoDeleteArticle(), WikiPageDbTestBase::testDoDeleteUpdates(), WikiPageDbTestBase::testDoEditContent(), WikiPageDbTestBase::testDoEditUpdates(), 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(), SvgHandlerTest::testGetIndependentMetaArray(), JpegTest::testGetIndependentMetaArray(), WatchedItemQueryServiceUnitTest::testGetWatchedItemsWithRecentChangeInfo_extension(), ExifBitmapTest::testGoodMetadata(), ApiParseTest::testHeadHtml(), ApiParseTest::testHeadItems(), ApiParseTest::testHeadItemsWithSkin(), ApiParseTest::testIndicators(), ApiParseTest::testIndicatorsWithSkin(), JpegMetadataExtractorTest::testInfiniteRead(), JpegMetadataExtractorTest::testInfiniteRead2(), RevisionDbTestBase::testInsertOn(), 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(), ApiStashEditTest::testIsInternal(), ExifBitmapTest::testIsInvalid(), JpegMetadataExtractorTest::testIso88591Comment(), ExifBitmapTest::testIsOldBroken(), ExifBitmapTest::testIsOldGood(), ApiParseTest::testIwlinks(), JpegTest::testJpegMetadataExtraction(), ApiParseTest::testLimitReports(), ChangeTagsTest::testListExplicitlyDefinedTags(), 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\Revision\RevisionStoreDbTestBase::testNewRevisionFromArchiveRow_getArchiveQueryInfo(), MediaWiki\Tests\Revision\RevisionStoreDbTestBase::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(), ApiStashEditTest::testStashedTextHash(), DatabaseIntegrationTest::testStoredFunctions(), ApiParseTest::testSuppressed(), ApiMoveTest::testSuppressRedirect(), ApiMoveTest::testSuppressRedirectNoPermission(), ApiParseTest::testTextNoContentModel(), BitmapMetadataHandlerTest::testTiffByteOrder(), TiffTest::testTiffMetadataExtraction(), ApiParseTest::testTitleNoText(), ApiParseTest::testTitleProvided(), ApiParseTest::testTitleWithNonMatchingRevId(), MediaWiki\Auth\ResetPasswordSecondaryAuthenticationProviderTest::testTryReset(), ApiParseTest::testUnfollowedRedirect(), DatabaseIntegrationTest::testUnknownTableCorruptsResults(), ChangeTagsTest::testUpdateTags(), JpegMetadataExtractorTest::testUtf8Comment(), ApiUserrightsTest::testWebToken(), SearchEngineTest::testWildcardSearch(), JpegMetadataExtractorTest::testXMPExtraction(), JpegMetadataExtractorTest::testXMPExtractionAltAppId(), Wikimedia\Rdbms\DatabasePostgres::textFieldSize(), Wikimedia\Rdbms\DatabaseMssql::textFieldSize(), Wikimedia\Rdbms\Database::textFieldSize(), ParameterizedPassword::toString(), MemcachedClient::touch(), TrackBlobs::trackOrphanText(), TrackBlobs::trackRevisions(), Wikimedia\Rdbms\DatabasePostgres::triggerExists(), RedisConnRef::tryCall(), HTMLForm::trySubmit(), RecentChangesUpdateJob::updateActiveUsers(), PopulateChangeTagDef::updateCountTag(), PopulateChangeTagDef::updateCountTagId(), MysqlInstaller::userDefinitelyExists(), MssqlInstaller::userExists(), Revision\RevisionStore::userWasLastToEdit(), 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 34 of file database.txt.

Referenced by below().

◆ contents

◆ layout

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.

Referenced by Revision\SlotRoleHandler::__construct().

◆ 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

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

◆ see

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

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