Manual:Cur table

Other language: 日本語...Translate this page!

<- MediaWiki architecture < Database layout

The cur table is where MediaWiki stores the current revision of an article.

"DESCRIBE cur" gives us:

One way of uniquely accessing the current version of an article is 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; these will differ in the cur_namespace field, though; 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 s/he was 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:Randompage 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