Manual:PostgreSQL

The purpose of this page is to collect information and experiences about running MediaWiki on PostgreSQL.

MediaWiki supports Postgres since 1.7 and as of 1.16 contain only a few minor bugs. MediaWiki requires Postgres 8.1 or later, and PG database support enabled in PHP.

Most of the common maintenance scripts work with Postgres however some of the more obscure ones might have problems.

Is PostgreSQL a good choice for MediaWiki?
Wikipedia uses MySQL so MediaWiki gets more testing on MySQL than PostgreSQL. While support for PostgreSQL is maintained by volunteers, most core functionality is working.

From MySQL to PostgreSQL
The mwdumper tool might help.

There is also mediawiki_mysql2postgres.pl in maintainance/postgres but it's not sure whether it really works.

From PostgreSQL to MySQL
This is generally not recommended as converting from Postgres data types back to MySQL is not as simple an operation as the reverse. There are however some scripts which may work.

tsearch2
The tsearch2 module needs to be installed to do the full-text searching of your wiki. Before Postgres 8.3 this was a separate module which needed separate installation, however as of Postgres 8.3 it is included in core and does not require any special steps.

Installing tsearch2 for older version varies depending on your operating system. Once you have tsearch2 installed, you need to install tsearch2 into the database you are going to use. This generally involves running the tsearch2.sql script as a superuser inside the database you want to install to. For example, if your tsearch2.sql file is located at /usr/share/postgresql/contrib/tsearch2.sql, you have a superuser named postgres, and you are adding tsearch2 to the wikidb database, the following command can be used:

psql -U postgres wikidb -f /usr/share/postgresql/contrib/tsearch2.sql

Note that this command may issue some warnings, but they are generally safe to ignore. You can test if tsearch2 is successfully installed by running:

psql -U postgres wikidb -c "select relname from pg_class where relname ~ '^pg_ts'"

You should see four tables starting with "pg_ts". If not, then tsearch was probably not installed.