MediaWiki  1.30.0
docs/databases/postgres.txt File Reference

Functions

This document describes the state of Postgres support in and is fairly well maintained The main code is very well while extensions are very hit and miss it is probably the most supported database after MySQL Much of the work in making MediaWiki database agnostic came about through the work of creating Postgres as and are nearing end of but without copying over all the usage comments General notes on the but these can almost always be programmed around *Although Postgres has a true BOOLEAN boolean columns are always mapped to as the code does not always treat the column as a boolean (which is limited to accepting true, false, 0, 1, t, or f) *The default data type for all VARCHAR
 

Variables

This document describes the state of Postgres support in and is fairly well maintained The main code is very well while extensions are very hit and miss it is probably the most supported database after MySQL Much of the work in making MediaWiki database agnostic came about through the work of creating Postgres as and are nearing end of but without copying over all the usage comments General notes on the but these can almost always be programmed around *Although Postgres has a true BOOLEAN boolean columns are always mapped to as the code does not always treat the column as a CHAR
 
This document describes the state of Postgres support in and is fairly well maintained The main code is very well while extensions are very hit and miss it is probably the most supported database after MySQL Much of the work in making MediaWiki database agnostic came about through the work of creating Postgres as and are nearing end of but without copying over all the usage comments General notes on the conversion
 
This document describes the state of Postgres support in and is fairly well maintained The main code is very well integrated
 
This document describes the state of Postgres support in and is fairly well maintained The main code is very well while extensions are very hit and miss it is probably the most supported database after MySQL Much of the work in making MediaWiki database agnostic came about through the work of creating Postgres as and are nearing end of life
 
This document describes the state of Postgres support in MediaWiki
 
This document describes the state of Postgres support in and is fairly well maintained The main code is very well while extensions are very hit and miss it is probably the most supported database after MySQL Much of the work in making MediaWiki database agnostic came about through the work of creating Postgres as and are nearing end of but without copying over all the usage comments General notes on the but these can almost always be programmed around *Although Postgres has a true BOOLEAN boolean columns are always mapped to SMALLINT
 
This document describes the state of Postgres support in and is fairly well maintained The main code is very well while extensions are very hit and miss Still
 
This document describes the state of Postgres support in and is fairly well maintained The main code is very well while extensions are very hit and miss it is probably the most supported database after MySQL Much of the work in making MediaWiki database agnostic came about through the work of creating Postgres support
 
This document describes the state of Postgres support in and is fairly well maintained The main code is very well while extensions are very hit and miss it is probably the most supported database after MySQL Much of the work in making MediaWiki database agnostic came about through the work of creating Postgres as and are nearing end of but without copying over all the usage comments General notes on the but these can almost always be programmed around *Although Postgres has a true BOOLEAN type
 

Function Documentation

◆ boolean()

This document describes the state of Postgres support in and is fairly well maintained The main code is very well while extensions are very hit and miss it is probably the most supported database after MySQL Much of the work in making MediaWiki database agnostic came about through the work of creating Postgres as and are nearing end of but without copying over all the usage comments General notes on the but these can almost always be programmed around* Although Postgres has a true BOOLEAN boolean columns are always mapped to as the code does not always treat the column as a boolean ( which is limited to accepting  true,
false  ,
,
,
,
or  f 
)

Variable Documentation

◆ CHAR

This document describes the state of Postgres support in and is fairly well maintained The main code is very well while extensions are very hit and miss it is probably the most supported database after MySQL Much of the work in making MediaWiki database agnostic came about through the work of creating Postgres as and are nearing end of but without copying over all the usage comments General notes on the but these can almost always be programmed around* Although Postgres has a true BOOLEAN boolean columns are always mapped to as the code does not always treat the column as a CHAR

Definition at line 41 of file postgres.txt.

◆ conversion

This document describes the state of Postgres support in and is fairly well maintained The main code is very well while extensions are very hit and miss it is probably the most supported database after MySQL Much of the work in making MediaWiki database agnostic came about through the work of creating Postgres as and are nearing end of but without copying over all the usage comments General notes on the conversion

Definition at line 22 of file postgres.txt.

◆ integrated

This document describes the state of Postgres support in and is fairly well maintained The main code is very well integrated

Definition at line 4 of file postgres.txt.

◆ life

This document describes the state of Postgres support in and is fairly well maintained The main code is very well while extensions are very hit and miss it is probably the most supported database after MySQL Much of the work in making MediaWiki database agnostic came about through the work of creating Postgres as and are nearing end of life
Initial value:
== Database schema ==
Postgres has its own schema file at maintenance/postgres/tables.sql.
The goal is to keep this file as close as possible to the canonical
schema at maintenance/tables.sql

Definition at line 22 of file postgres.txt.

◆ MediaWiki

those of us who don t want or need it can just leave it out The extensions don t even have to be shipped with MediaWiki
Initial value:
== Overview ==
Support for PostgreSQL has been available since version 1.7

Definition at line 4 of file postgres.txt.

Referenced by MediaWikiTest::testTryNormaliseRedirect().

◆ SMALLINT

This document describes the state of Postgres support in and is fairly well maintained The main code is very well while extensions are very hit and miss it is probably the most supported database after MySQL Much of the work in making MediaWiki database agnostic came about through the work of creating Postgres as and are nearing end of but without copying over all the usage comments General notes on the but these can almost always be programmed around* Although Postgres has a true BOOLEAN boolean columns are always mapped to SMALLINT

Definition at line 22 of file postgres.txt.

◆ Still

This document describes the state of Postgres support in and is fairly well maintained The main code is very well while extensions are very hit and miss Still

Definition at line 4 of file postgres.txt.

◆ support

This document describes the state of Postgres support in and is fairly well maintained The main code is very well while extensions are very hit and miss it is probably the most supported database after MySQL Much of the work in making MediaWiki database agnostic came about through the work of creating Postgres support
Initial value:
== Required versions ==
The current minimum version of PostgreSQL for MediaWiki is 8.1.
It is expected that this will be raised to 8.3 at some point

Definition at line 14 of file postgres.txt.

◆ type

< input type="submit" name="fulltext" class="mw-ui-button" value="Search full text"/></p ></form ></div > ! end ! test InputBox type

Definition at line 22 of file postgres.txt.

Referenced by MediaWiki\Widget\DateTimeInputWidget::__construct(), ChangesFeed::__construct(), PoolCounterWork::__construct(), SearchIndexFieldDefinition::__construct(), ProtectedPagesPager::__construct(), JobQueue::__construct(), MediaWiki\Auth\Throttler::__construct(), LogPage::__construct(), Exif::__construct(), JobSpecification::__construct(), Site::__construct(), ChangesListFilterGroup::__construct(), ManualLogEntry::__construct(), JSNode::__construct(), LogPage::addEntry(), JobQueue::batchPush(), JobQueueDB::claimOldest(), JobQueueDB::claimRandom(), MediaWiki\Auth\Throttler::clear(), JobQueueRedis::doAck(), JobQueueDB::doAck(), JobQueueRedis::doBatchPush(), JobQueueDB::doBatchPushInternal(), JobQueueMemory::doDelete(), JobQueueDB::doDelete(), JobQueueDB::doIsEmpty(), JobQueueDB::doPop(), JobQueueRedis::doPop(), JobQueueRedis::encodeQueueName(), SpecialUnblock::execute(), UpdateLogging::execute(), ChangesFeed::execute(), SkinFallbackTemplate::execute(), JSParser::Expression(), JobQueueDB::getCacheKey(), LogPage::getDescription(), SpecialUnblock::getFields(), MediaWiki\Widget\DateTimeInputWidget::getInputElement(), File::getIsSafeFileUncached(), RedisLockManager::getLocksOnServer(), LogPage::getName(), ProtectedPagesPager::getQueryInfo(), JobQueueMemory::getQueueData(), Block::getRangeEnd(), Block::getRangeStart(), LogPage::getRestriction(), JobQueue::getRootJobCacheKey(), Gadget::getType(), MWExceptionRenderer::googleSearchForm(), MediaWiki\Auth\Throttler::increase(), SearchIndexFieldDefinition::merge(), Block::newLoad(), AtomFeed::outHeader(), AtomFeed::outItem(), JobQueue::pop(), JobQueueDB::recycleAndDeleteStaleJobs(), LogPage::saveContent(), SpecialBlock::setParameter(), Block::setTarget(), WikiRevision::setType(), LogEventsList::showLogExtract(), and JSParser::Statement().

file
We ve cleaned up the code here by removing clumps of infrequently used code and moving them off somewhere else It s much easier for someone working with this code to see what s _really_ going and make changes or fix bugs In we can take all the code that deals with the little used title reversing we can concentrate it all in an extension file
Definition: hooks.txt:91
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(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
version
Prior to version
Definition: maintenance.txt:1
own
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your own(ChangesListBooleanFilterGroup or ChangesListStringOptionsFilterGroup). If you create new groups
MediaWiki
A helper class for throttling authentication attempts.
will
</td >< td > &</td >< td > t want your writing to be edited mercilessly and redistributed at will
Definition: All_system_messages.txt:914
some
I won t presume to tell you how to I m just describing the methods I chose to use for myself If you do choose to follow these it will probably be easier for you to collaborate with others on the but if you want to contribute without by all means do which work well I also use K &R brace matching style I know that s a religious issue for some
Definition: design.txt:79
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
of
globals txt Globals are evil The original MediaWiki code relied on globals for processing context far too often MediaWiki development since then has been a story of slowly moving context out of global variables and into objects Storing processing context in object member variables allows those objects to be reused in a much more flexible way Consider the elegance of
Definition: globals.txt:10
that
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global then executing the whole list after the page is displayed We don t do anything smart like collating updates to the same table or such because the list is almost always going to have just one item on if that
Definition: deferred.txt:11