Movatterモバイル変換


[0]ホーム

URL:


Jump to content
MediaWiki
Search

Manual:page table

From mediawiki.org
Translate this page
Languages:
Manual:Contents
MediaWiki database layout
page table
MediaWiki version:
1.5

Thepage 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 inr6710, in MediaWiki 1.5.

The text of the page itself is stored in thetext table.To retrieve the text of an article during a typical page view, MediaWiki first searches for the row in thepage table based onpage_namespace andpage_title matching the page name supplied in the URL.Then,page_latest is used to search therevision table forrev_id, andrev_text_id is obtained in the process.The value obtained forrev_text_id is used to search forold_id in thetext table to retrieve the text.When a page is deleted, the revisions are moved to thearchive table.

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

Fields

[edit]

page_id

[edit]

Uniquely identifyingprimary key.This value is preserved across edits and renames.

Page IDs do not change when pages aremoved, but theymay change when pages aredeleted and then restored.As of MediaWiki 1.27, the historical page ID persists in thearchive table, and restored pages attempt to reclaim their old page ID.

For further information, see:

page_namespace

[edit]

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

This field contains the number of the page'snamespace.The values range from 0 to 99 for the core namespaces, and from 100 to 10,000 forcustom namespaces.

page_title

[edit]

The sanitizedpage title, without the namespace, with a maximum of 255 characters (binary).It is stored as text, with spaces replaced by underscores.The real title shown in articles is just this title with underscores (_) converted to spaces ( ).For example, a page titled "Talk:Foo Bar" would have "Foo_Bar" in this field.

page_is_redirect

[edit]

A value of1 here indicates the article is a redirect; it is0 in all other cases.

page_is_new

[edit]

This field stores whether the page is new, meaning it either has only one revision or has not been edited since beingrestored, even if there is more than one revision.If the field contains a value of1, then it indicates that the page is new; otherwise, it is0.Rollback links are not displayed if the page is new, since there is nothing to roll back to.

page_random

[edit]

Random decimal value, between 0 and 1, used forSpecial:Random (seeManual:Random page for more details).Generated bywfRandom().

Around 2005, a bug caused these random values to be non-uniform. Since the field is set at page creation, wikis that have existed for a long time might still have some of these erroneous values.SeeT208909.

page_touched

[edit]

Thistimestamp 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.Set to$dbw->timestamp() at the time of page creation.

page_links_updated

[edit]
MediaWiki version:
1.23

This timestamp is updated whenever a page is re-parsed and it has all the link tracking tables updated for it.This is useful for de-duplicating expensive backlink update jobs.Set to the default value of NULL when the page is created byWikiPage::insertOn().

page_latest

[edit]

This is a foreign key torev_id for the current revision.It may be 0 during page creation.It needs to link to a revision with a validrevision.rev_page, or there will be the "The revision #0 of the page named 'Foo' does not exist" error when one tries to view the page.Can be obtained viaWikiPage::getLatest().

page_len

[edit]

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

This however, does not apply to images which still have records in this table.Instead, the uncompressed length in bytes of thedescription for the file is used as the latter is in thetext.old_text field.

TheWikipage class inincludes/WikiPage.php has two methods, viz.insertOn() andupdateRevisionOn() that are responsible for populating these details.

page_content_model

[edit]
MediaWiki version:
1.21

Content model, see CONTENT_MODEL_XXX constants.Comparable torevision.rev_content_model.

page_lang

[edit]
MediaWiki version:
1.24

Page content language.Set to the default value of NULL at the time of page creation.

page_restrictions

[edit]
MediaWiki version:
1.9

Comma-separated set of permission keys indicating who can move or edit the page.Edit and move sections are separated by a colon (e.g., "edit=autoconfirmed,sysop:move=sysop").

MediaWiki versions:
1.10 – 1.38
Beginning with MediaWiki 1.10, page protection controls were moved to thepage_restrictions table, so this field will be empty in databases generated by more current versions of MediaWiki.(removed in 1.39)

page_counter

[edit]
MediaWiki version:
1.24

Number of times the page has been viewed.This feature was completely removed in MediaWiki 1.25, following arequest for comment.Even before that, many sites including Wikimedia projects disabled it to increase performance; seeManual:$wgDisableCounters for details.

titlevector

[edit]
Only used byPostgreSQL

Used instead of thesearchindex table by PostgreSQL to facilitate fulltext search.

Schema summary

[edit]
MediaWiki version:
1.43

DESCRIBEpage;

+--------------------+---------------------+------+-----+---------+----------------+| 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         | varbinary(255)      | NO   |     | NULL    |                || page_is_redirect   | tinyint(3) unsigned | NO   | MUL | 0       |                || page_is_new        | tinyint(3) unsigned | NO   |     | 0       |                || page_random        | double unsigned     | NO   | MUL | NULL    |                || page_touched       | binary(14)          | NO   |     | NULL    |                || page_links_updated | binary(14)          | YES  |     | NULL    |                || page_latest        | int(10) unsigned    | NO   |     | NULL    |                || page_len           | int(10) unsigned    | NO   | MUL | NULL    |                || page_content_model | varbinary(32)       | YES  |     | NULL    |                || page_lang          | varbinary(35)       | YES  |     | NULL    |                |+--------------------+---------------------+------+-----+---------+----------------+
MediaWiki versions:
1.39 – 1.42

DESCRIBEpage;

+--------------------+---------------------+------+-----+---------+----------------+| 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         | varbinary(255)      | NO   |     | NULL    |                || page_is_redirect   | tinyint(3) unsigned | NO   | MUL | 0       |                || page_is_new        | tinyint(3) unsigned | NO   |     | 0       |                || page_random        | double unsigned     | NO   | MUL | NULL    |                || page_touched       | binary(14)          | NO   |     | NULL    |                || page_links_updated | varbinary(14)       | YES  |     | NULL    |                || page_latest        | int(10) unsigned    | NO   |     | NULL    |                || page_len           | int(10) unsigned    | NO   | MUL | NULL    |                || page_content_model | varbinary(32)       | YES  |     | NULL    |                || page_lang          | varbinary(35)       | YES  |     | NULL    |                |+--------------------+---------------------+------+-----+---------+----------------+
MediaWiki versions:
1.36 – 1.38
Gerrit change 690067

DESCRIBEpage;

+--------------------+---------------------+------+-----+---------+----------------+| 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         | varbinary(255)      | NO   |     | NULL    |                || page_restrictions  | tinyblob            | YES  |     | NULL    |                || page_is_redirect   | tinyint(3) unsigned | NO   | MUL | 0       |                || page_is_new        | tinyint(3) unsigned | NO   |     | 0       |                || page_random        | double unsigned     | NO   | MUL | NULL    |                || page_touched       | binary(14)          | NO   |     | NULL    |                || page_links_updated | varbinary(14)       | YES  |     | NULL    |                || page_latest        | int(10) unsigned    | NO   |     | NULL    |                || page_len           | int(10) unsigned    | NO   | MUL | NULL    |                || page_content_model | varbinary(32)       | YES  |     | NULL    |                || page_lang          | varbinary(35)       | YES  |     | NULL    |                |+--------------------+---------------------+------+-----+---------+----------------+
MediaWiki version:
1.35
Gerrit change 581141

DESCRIBEpage;

+--------------------+---------------------+------+-----+----------------+----------------+| 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         | varbinary(255)      | NO   |     | NULL           |                || page_restrictions  | tinyblob            | YES  |     | NULL           |                || page_is_redirect   | tinyint(3) unsigned | NO   | MUL | 0              |                || page_is_new        | tinyint(3) unsigned | NO   |     | 0              |                || page_random        | double unsigned     | NO   | MUL | NULL           |                || page_touched       | binary(14)          | NO   |     |                |                || page_links_updated | varbinary(14)       | YES  |     | NULL           |                || page_latest        | int(10) unsigned    | NO   |     | NULL           |                || page_len           | int(10) unsigned    | NO   | MUL | NULL           |                || page_content_model | varbinary(32)       | YES  |     | NULL           |                || page_lang          | varbinary(35)       | YES  |     | NULL           |                |+--------------------+---------------------+------+-----+----------------+----------------+
MediaWiki versions:
1.25 – 1.34
Gerrit change 167655

DESCRIBEpage;

+--------------------+---------------------+------+-----+----------------+----------------+| 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         | varbinary(255)      | NO   |     | NULL           |                || page_restrictions  | tinyblob            | NO   |     | NULL           |                || page_is_redirect   | tinyint(3) unsigned | NO   | MUL | 0              |                || page_is_new        | tinyint(3) unsigned | NO   |     | 0              |                || page_random        | double unsigned     | NO   | MUL | NULL           |                || page_touched       | binary(14)          | NO   |     |                |                || page_links_updated | varbinary(14)       | YES  |     | NULL           |                || page_latest        | int(10) unsigned    | NO   |     | NULL           |                || page_len           | int(10) unsigned    | NO   | MUL | NULL           |                || page_content_model | varbinary(32)       | YES  |     | NULL           |                || page_lang          | varbinary(35)       | YES  |     | NULL           |                |+--------------------+---------------------+------+-----+----------------+----------------+
MediaWiki version:
1.24
Gerrit change 135312

DESCRIBEpage;

+--------------------+---------------------+------+-----+---------+----------------+| 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) binary | NO   |     | NULL    |                || page_restrictions  | tinyblob            | NO   |     | NULL    |                || page_counter       | bigint(20) unsigned | NO   |     | 0       |                || page_is_redirect   | tinyint(3) unsigned | NO   | MUL | 0       |                || page_is_new        | tinyint(3) unsigned | NO   |     | 0       |                || page_random        | real unsigned       | NO   | MUL | NULL    |                || page_touched       | binary(14)          | NO   |     | NULL    |                || page_links_updated | varbinary(14)       | YES  |     | NULL    |                || page_latest        | int(10) unsigned    | NO   |     | NULL    |                || page_len           | int(10) unsigned    | NO   | MUL | NULL    |                || page_content_model | varbinary(32)       | YES  |     | NULL    |                || page_lang          | varbinary(35)       | YES  |     | NULL    |                |+--------------------+---------------------+------+-----+---------+----------------+
MediaWiki version:
1.23
Gerrit change 101170

DESCRIBEpage;

+--------------------+---------------------+------+-----+---------+----------------+| 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) binary | NO   |     | NULL    |                || page_restrictions  | tinyblob            | NO   |     | NULL    |                || page_counter       | bigint(20) unsigned | NO   |     | 0       |                || page_is_redirect   | tinyint(3) unsigned | NO   | MUL | 0       |                || page_is_new        | tinyint(3) unsigned | NO   |     | 0       |                || page_random        | real unsigned       | NO   | MUL | NULL    |                || page_touched       | binary(14)          | NO   |     | NULL    |                || page_links_updated | varbinary(14)       | YES  |     | NULL    |                || page_latest        | int(10) unsigned    | NO   |     | NULL    |                || page_len           | int(10) unsigned    | NO   | MUL | NULL    |                || page_content_model | varbinary(32)       | YES  |     | NULL    |                |+--------------------+---------------------+------+-----+---------+----------------+
MediaWiki versions:
1.21 – 1.22

DESCRIBEpage;

+--------------------+---------------------+------+-----+---------+----------------+| 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) binary | NO   |     | NULL    |                || page_restrictions  | tinyblob            | NO   |     | NULL    |                || page_counter       | bigint(20) unsigned | NO   |     | 0       |                || page_is_redirect   | tinyint(3) unsigned | NO   | MUL | 0       |                || page_is_new        | tinyint(3) unsigned | NO   |     | 0       |                || page_random        | real 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    |                || page_content_model | varbinary(32)       | YES  |     | NULL    |                |+--------------------+---------------------+------+-----+---------+----------------+
MediaWiki versions:
1.19 – 1.20

DESCRIBEpage;

+-------------------+---------------------+------+-----+---------+----------------+| 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) binary | NO   |     | NULL    |                || page_restrictions | tinyblob            | NO   |     | NULL    |                || page_counter      | bigint(20) unsigned | NO   |     | 0       |                || page_is_redirect  | tinyint(3) unsigned | NO   | MUL | 0       |                || page_is_new       | tinyint(3) unsigned | NO   |     | 0       |                || page_random       | real 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 versions:
1.10 – 1.18

DESCRIBEpage;

+-------------------+---------------------+------+-----+---------+----------------+| 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) binary | 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       | real 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 versions:
1.5 – 1.9

DESCRIBEpage;

+-------------------+---------------------+------+-----+---------+----------------+| 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) binary | 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       | real unsigned       | NO   | MUL | NULL    |                || page_touched      | char(14) binary     | NO   |     | NULL    |                || page_latest       | int(8) unsigned     | NO   |     | NULL    |                || page_len          | int(8) unsigned     | NO   | MUL | NULL    |                |+-------------------+---------------------+------+-----+---------+----------------+

Indexes

[edit]
MediaWiki version:
1.28

SHOWINDEXINpage;

+-------+------------+-----------------------------+--------------+------------------+-----------+-------------+----------+--------+------+------------+---------+---------------+| Table | Non_unique | Key_name                    | Seq_in_index | Column_name      | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |+-------+------------+-----------------------------+--------------+------------------+-----------+-------------+----------+--------+------+------------+---------+---------------+| page  |          0 | PRIMARY                     |            1 | page_id          | A         |           0 |     NULL | NULL   |      | BTREE      |         |               || page  |          0 | page_name_title             |            1 | page_namespace   | A         |           0 |     NULL | NULL   |      | BTREE      |         |               || page  |          0 | page_name_title             |            2 | page_title       | A         |           0 |     NULL | NULL   |      | BTREE      |         |               || page  |          1 | page_random                 |            1 | page_random      | A         |           0 |     NULL | NULL   |      | BTREE      |         |               || page  |          1 | page_len                    |            1 | page_len         | A         |           0 |     NULL | NULL   |      | BTREE      |         |               || page  |          1 | page_redirect_namespace_len |            1 | page_is_redirect | A         |           0 |     NULL | NULL   |      | BTREE      |         |               || page  |          1 | page_redirect_namespace_len |            2 | page_namespace   | A         |           0 |     NULL | NULL   |      | BTREE      |         |               || page  |          1 | page_redirect_namespace_len |            3 | page_len         | A         |           0 |     NULL | NULL   |      | BTREE      |         |               |+-------+------------+-----------------------------+--------------+------------------+-----------+-------------+----------+--------+------+------------+---------+---------------+

Sample MySQL code

[edit]

Listing pages and relations with other essential tables

[edit]

The following code will select the most recent versions of all articles assuming thatcompression orexternal storage is not in use:

SELECTpage_id,page_namespace,page_title,page_latest"rev_id",old_text"text"FROMpageINNERJOINslotsonpage_latest=slot_revision_idINNERJOINslot_rolesonslot_role_id=role_idandrole_name='main'INNERJOINcontentonslot_content_id=content_idinnerjointextonsubstring(content_address,4)=old_idandleft(content_address,3)="tt:"andold_flags="utf-8";

Other important considerations:

  • to find pages innamespace 0 addp.page_namespace = 0
  • to find pages that are not redirects addp.page_is_redirect = 0

These additional statements can be added either as conditions to a Where statement or as conditions on the appropriateINNER JOIN statement.

See also

[edit]
Engines
Current
Former
Technical documentation
Configuration
Development
Core tables
Current
Former
Retrieved from "https://www.mediawiki.org/w/index.php?title=Manual:Page_table&oldid=7751301"
Category:

[8]ページ先頭

©2009-2025 Movatter.jp