Manual:Page table

From MediaWiki.org
(Redirected from Page table)
Jump to: navigation, search
Manual:Contents MediaWiki database layout Page table


Contents

MediaWiki version: 1.5

The page table can be considered the "core of the wiki". Each page in a MediaWiki installation has an entry here which identifies it by title and contains some essential metadata. It was first introduced in r6710, in MediaWiki 1.5.

The text of the page itself is stored in the text table. To retrieve the text of an article, MediaWiki first searches for page_title in this table. Then, page_latest is used to search the revision table for rev_id, and rev_text_id is obtained in the process. The value obtained for rev_text_id is used to search for old_id in the text table to retrieve the text.

Note Note: If you want to completely delete a page manually from the database, be sure to delete the entry for the page in the page table, and for all the page's revisions in the revision table, and all of the text rows corresponding only to the page in the text table. This can be done by deleting the page row, then running maintenance/deleteOrphanedRevisions.php.

[edit] Fields

[edit] page_id

Uniquely identifying primary key. This value is preserved across edits and renames, but not deletion and recreation. For example, for this page, page_id = 10501. [1][2]

[edit] page_namespace

A page name is broken into a namespace and a title. The namespace keys are UI-language-independent constants, defined in includes/Defines.php.

This field contains the number of the page's namespace. The values range from 0 to 15 for the standard namespaces, and from 100 to 255 for custom namespaces.

[edit] page_title

The sanitized page title, without the title of its namespace. It is stored as text, with spaces replaced by underscores. The real title showed in articles is just this title with underscores (_) converted to spaces ( ).

[edit] page_restrictions

MediaWiki version: 1.9 and earlier

Comma-separated set of permission keys indicating who can move or edit the page.

Note Note: Beginning with MediaWiki 1.10, page protection controls were moved to the page restrictions table.

[edit] page_counter

Number of times this page has been viewed. Note that on some sites (e.g. Wikimedia sites) incrementing this field is disabled so as to increase performance - see the $wgDisableCounters global.

[edit] page_is_redirect

A value of 1 here indicates the article is a redirect; it is 0 in all other cases.

[edit] page_is_new

This field stores whether the page is a new entry or not; if the field contains a value of 1, then it indicates that the page is a new entry with only one edit. It is 0 in all other cases.

[edit] page_random

Random decimal value, between 0 and 1, used for Special:Randompage.

[edit] page_touched

This timestamp is updated whenever the page changes in a way requiring it to be re-rendered, invalidating caches. Aside from editing this includes permission changes, creation or deletion of linked pages, and alteration of contained templates.

[edit] page_latest

This is a foreign key to rev_id for the current revision. It may be 0 during page creation.

[edit] page_len

Uncompressed length in bytes of the page's current source text.

[edit] Schema summary

MediaWiki version: 1.10 and earlier

DESCRIBE page; in MediaWiki 1.5 through 1.10 results in:

+-----------------------+---------------------+------+-----+---------+----------------+
| Field                 | Type                | Null | Key | Default | Extra          |
+-----------------------+---------------------+------+-----+---------+----------------+
| page_id               | int(8) unsigned     | NO   | PRI | NULL    | auto_increment |
| page_namespace        | int(11)             | NO   | MUL | NULL    |                |
| page_title            | varchar(255)        | NO   |     | NULL    |                |
| page_restrictions     | tinyblob            | NO   |     | NULL    |                |
| page_counter          | bigint(20) unsigned | NO   |     | 0       |                |
| page_is_redirect      | tinyint(1) unsigned | NO   |     | 0       |                |
| page_is_new           | tinyint(1) unsigned | NO   |     | 0       |                |
| page_random           | double unsigned     | NO   | MUL | NULL    |                |
| page_touched          | char(14)            | NO   |     | NULL    |                |
| page_latest           | int(8) unsigned     | NO   |     | NULL    |                |
| page_len              | int(8) unsigned     | NO   | MUL | NULL    |                |
+-----------------------+---------------------+------+-----+---------+----------------+
MediaWiki version: 1.11

DESCRIBE page; in MediaWiki 1.11 results in:

+-----------------------+---------------------+------+-----+---------+----------------+
| Field                 | Type                | Null | Key | Default | Extra          |
+-----------------------+---------------------+------+-----+---------+----------------+
| page_id               | int(10) unsigned    | NO   | PRI | NULL    | auto_increment |
| page_namespace        | int(11)             | NO   | MUL | NULL    |                |
| page_title            | varchar(255)        | NO   |     | NULL    |                |
| page_restrictions     | tinyblob            | NO   |     | NULL    |                |
| page_counter          | bigint(20) unsigned | NO   |     | 0       |                |
| page_is_redirect      | tinyint(3) unsigned | NO   |     | 0       |                |
| page_is_new           | tinyint(3) unsigned | NO   |     | 0       |                |
| page_random           | double unsigned     | NO   | MUL | NULL    |                |
| page_touched          | binary(14)          | NO   |     | NULL    |                |
| page_latest           | int(10) unsigned    | NO   |     | NULL    |                |
| page_len              | int(10) unsigned    | NO   | MUL | NULL    |                |
+-----------------------+---------------------+------+-----+---------+----------------+
MediaWiki version: 1.12

DESCRIBE page; in MediaWiki 1.12 results in:

+-----------------------+---------------------+------+-----+---------+----------------+
| Field                 | Type                | Null | Key | Default | Extra          |
+-----------------------+---------------------+------+-----+---------+----------------+
| page_id               | int(8) unsigned     | NO   | PRI | NULL    | auto_increment |
| page_namespace        | int(11)             | NO   | MUL | NULL    |                |
| page_title            | varchar(255)        | NO   |     | NULL    |                |
| page_restrictions     | tinyblob            | NO   |     | NULL    |                |
| page_counter          | bigint(20) unsigned | NO   |     | 0       |                |
| page_is_redirect      | tinyint(1) unsigned | NO   |     | 0       |                |
| page_is_new           | tinyint(1) unsigned | NO   |     | 0       |                |
| page_random           | double unsigned     | NO   | MUL | NULL    |                |
| page_touched          | char(14)            | NO   |     | NULL    |                |
| page_latest           | int(8) unsigned     | NO   |     | NULL    |                |
| page_len              | int(8) unsigned     | NO   | MUL | NULL    |                |
+-----------------------+---------------------+------+-----+---------+----------------+

[edit] Sample MySQL Code

The following code will select the most recent versions of all articles in the wikidb:

Select

p.page_id as "Page ID",
p.page_title as "Page Title",
r.rev_text_id as "Revision ID",
t.old_id as "Text ID"

from

wikidb.page p
inner join wikidb.revision r
on p.page_latest = r.rev_id
inner join wikidb.text t
on r.rev_text_id = t.old_id;


Other important considerations:


These additional statements can be added either as conditions to a Where statement or as conditions on the appropriate Inner Join statement.

[edit] Notes

Language: English  • 日本語
Personal tools
Namespaces
Variants
Actions
Site
Support
Download
Development
Communication
Toolbox