Manual:cur table
↑ Manual:Contents | MediaWiki database layout | cur table |
MediaWiki version: | ≤ 1.4 |
The cur
table was used in older versions of MediaWiki wikis to store the current revision of a page.
In MediaWiki 1.5 the contents of the cur
table and of the old table were merged together and moved to the page table, the revision table and the text table.
After running the updater when updating from MediaWiki 1.4 or older to a newer version, this table is not needed anymore and can be safely deleted.
One way of uniquely accessing the current version of an article was via cur_id
, another is through the combination of cur_title
and cur_namespace
.
Note that there may be several entries with the same cur_title
in the cur
table, for example, "Stuff" and "Talk:Stuff" will differ in the cur_namespace
field; the integer values and their corresponding names (e.g., 1="Talk") are set in the appropriate LanguageXX.php file and are also shown using variables.
Some information in the cur
table relates to the last change of the article (which might well be its creation, which is indicated by cur_is_new
).
cur_text
holds the wikitext.
cur_comment
is the edit summary of the last change; cur_user
and cur_user_text
identify the user that made that change, where cur_user
holds the ID of that user, if they were logged in.
cur_timestamp
notes the time and date of the change, cur_minor_edit
carries the state of that checkbox upon saving.
The other fields mainly serve decorative purposes:
- cur_restrictions - says who can edit that page. Given the nature of Wikipedia, this field will be empty for all articles, except the protected ones.
- cur_counter - was once supposed to count the views of each page. That function was turned off due to heavy database traffic and some bugs.
- cur_is_redirect - is a fast and easy way of checking if the
cur_text
starts with "#REDIRECT". - cur_random - is used by the "random page" function. It stores a randomly selected floating-point number between 0 and 1. When someone visits Special:Random the wiki picks another random number and grabs the page with the closest
cur_random
value. This seems to be much, much faster than 'ORDER BY RAND() LIMIT 1' with large numbers of pages, as it's a simple column index lookup. - inverse_timestamp - inverse of the
cur_timestamp
field for reverse sorting on mysql 3.x; this isn't necessary on mysql 4.x and at some point should be removed. - cur_touched - timestamp for cache invalidation; updated on page save and the creation/deletion of linked pages
Schema summary
[edit]MediaWiki version: | ≤ 1.4 |
DESCRIBE cur;
+-------------------+---------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------------------+---------------------+------+-----+---------+----------------+ | cur_id | int(8) unsigned | | PRI | 0 | auto_increment | | cur_namespace | tinyint(2) unsigned | | MUL | | | | cur_title | varchar(255) binary | | MUL | | | | cur_text | mediumtext | | | | | | cur_comment | tinyblob | | | | | | cur_user | int(5) unsigned | | MUL | 0 | | | cur_user_text | varchar(255) binary | | MUL | | | | cur_timestamp | varchar(14) binary | | MUL | | | | cur_restrictions | tinyblob | | | | | | cur_counter | bigint(20) unsigned | | | 0 | | | cur_is_redirect | tinyint(1) unsigned | | | 0 | | | cur_minor_edit | tinyint(1) unsigned | | | 0 | | | cur_is_new | tinyint(1) unsigned | | | 0 | | | cur_random | double unsigned | | MUL | 0 | | | inverse_timestamp | varchar(14) binary | | | | | | cur_touched | varchar(14) binary | | | | | +-------------------+---------------------+------+-----+---------+----------------+
Indexes
[edit]MediaWiki version: | 1.4 |
SHOW INDEX IN cur;
+-------+------------+------------------------------+--------------+-------------------+-----------+-------------+----------+--------+------+------------+---------+---------------+ | Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment | +-------+------------+------------------------------+--------------+-------------------+-----------+-------------+----------+--------+------+------------+---------+---------------+ | cur | 0 | PRIMARY | 1 | cur_id | A | 0 | NULL | NULL | | BTREE | | | | cur | 0 | name_title | 1 | cur_namespace | A | 0 | NULL | NULL | | BTREE | | | | cur | 0 | name_title | 2 | cur_title | A | 0 | NULL | NULL | | BTREE | | | | cur | 1 | cur_title | 1 | cur_title | A | 0 | 20 | NULL | | BTREE | | | | cur | 1 | cur_timestamp | 1 | cur_timestamp | A | 0 | NULL | NULL | | BTREE | | | | cur | 1 | cur_random | 1 | cur_random | A | 0 | NULL | NULL | | BTREE | | | | cur | 1 | name_title_timestamp | 1 | cur_namespace | A | 0 | NULL | NULL | | BTREE | | | | cur | 1 | name_title_timestamp | 2 | cur_title | A | 0 | NULL | NULL | | BTREE | | | | cur | 1 | name_title_timestamp | 3 | inverse_timestamp | A | 0 | NULL | NULL | | BTREE | | | | cur | 1 | user_timestamp | 1 | cur_user | A | 0 | NULL | NULL | | BTREE | | | | cur | 1 | user_timestamp | 2 | inverse_timestamp | A | 0 | NULL | NULL | | BTREE | | | | cur | 1 | usertext_timestamp | 1 | cur_user_text | A | 0 | NULL | NULL | | BTREE | | | | cur | 1 | usertext_timestamp | 2 | inverse_timestamp | A | 0 | NULL | NULL | | BTREE | | | | cur | 1 | namespace_redirect_timestamp | 1 | cur_namespace | A | 0 | NULL | NULL | | BTREE | | | | cur | 1 | namespace_redirect_timestamp | 2 | cur_is_redirect | A | 0 | NULL | NULL | | BTREE | | | | cur | 1 | namespace_redirect_timestamp | 3 | cur_timestamp | A | 0 | NULL | NULL | | BTREE | | | | cur | 1 | id_title_ns_red | 1 | cur_id | A | 0 | NULL | NULL | | BTREE | | | | cur | 1 | id_title_ns_red | 2 | cur_title | A | 0 | NULL | NULL | | BTREE | | | | cur | 1 | id_title_ns_red | 3 | cur_namespace | A | 0 | NULL | NULL | | BTREE | | | | cur | 1 | id_title_ns_red | 4 | cur_is_redirect | A | 0 | NULL | NULL | | BTREE | | | +-------+------------+------------------------------+--------------+-------------------+-----------+-------------+----------+--------+------+------------+---------+---------------+