diff options
author | Nils Adermann <naderman@naderman.de> | 2007-03-13 22:00:55 +0000 |
---|---|---|
committer | Nils Adermann <naderman@naderman.de> | 2007-03-13 22:00:55 +0000 |
commit | ce8b00801edabd8de8b88891d6997309e7ca0459 (patch) | |
tree | 65788f228055ca6d8b50242ee6f94ff914de70d4 /phpBB/install | |
parent | 5e06885ea4acd2dbe0c05fdb3db61577b79669d1 (diff) | |
download | forums-ce8b00801edabd8de8b88891d6997309e7ca0459.tar forums-ce8b00801edabd8de8b88891d6997309e7ca0459.tar.gz forums-ce8b00801edabd8de8b88891d6997309e7ca0459.tar.bz2 forums-ce8b00801edabd8de8b88891d6997309e7ca0459.tar.xz forums-ce8b00801edabd8de8b88891d6997309e7ca0459.zip |
- improvements to search indexing performance, espacially tidy() by adding a word_count column, the database update from b5 to next version will take quite a while on bigger databases, I also lowered the default common word threshold from 20 to 5 percent, big boards might want to use 3 or 2 percent, 20 was way too high
- added some keys to ACL tables, great improvement of auth query performance
- we will only add new language strings to install.php language file and won't modify any, if a language file is updated before phpBB is updated, the updater will not overwrite the user's language with english if install.php was modified
git-svn-id: file:///svn/phpbb/trunk@7182 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/install')
-rw-r--r-- | phpBB/install/database_update.php | 102 | ||||
-rw-r--r-- | phpBB/install/install_update.php | 7 | ||||
-rw-r--r-- | phpBB/install/schemas/firebird_schema.sql | 7 | ||||
-rw-r--r-- | phpBB/install/schemas/mssql_schema.sql | 15 | ||||
-rw-r--r-- | phpBB/install/schemas/mysql_40_schema.sql | 13 | ||||
-rw-r--r-- | phpBB/install/schemas/mysql_41_schema.sql | 13 | ||||
-rw-r--r-- | phpBB/install/schemas/oracle_schema.sql | 9 | ||||
-rw-r--r-- | phpBB/install/schemas/postgres_schema.sql | 5 | ||||
-rw-r--r-- | phpBB/install/schemas/schema_data.sql | 2 | ||||
-rw-r--r-- | phpBB/install/schemas/sqlite_schema.sql | 7 |
10 files changed, 166 insertions, 14 deletions
diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index b6b8e1f352..85b84d0b38 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -320,6 +320,7 @@ $database_update_info = array( 'session_forwarded_for' => array('VCHAR:255', ''), ), ), + // Change the following columns... 'change_columns' => array( USERS_TABLE => array( 'user_options' => array('UINT:11', 895), @@ -353,6 +354,13 @@ $database_update_info = array( ), // Changes from 3.0.b5 to the next version '3.0.b5' => array( + // Add the following columns + 'add_columns' => array( + SEARCH_WORDLIST_TABLE => array( + 'word_count' => array('UINT', 0), + ), + ), + // Change the following columns... 'change_columns' => array( TOPICS_TABLE => array( 'poll_title' => array('STEXT_UNI', ''), @@ -367,10 +375,24 @@ $database_update_info = array( 'username_clean', ), ), + 'add_index' => array( + SEARCH_WORDLIST_TABLE => array( + 'wrd_cnt' => array('word_count'), + ), + ACL_GROUPS_TABLE => array( + 'auth_role_id' => array('auth_role_id'), + ), + ACL_USERS_TABLE => array( + 'auth_role_id' => array('auth_role_id'), + ), + ACL_ROLES_DATA_TABLE => array( + 'auth_option_id' => array('auth_option_id'), + ), + ), // Add the following unique indexes 'add_unique_index' => array( SEARCH_WORDMATCH_TABLE => array( - 'unique_match' => array('word_id', 'post_id', 'title_match'), + 'unique_match' => array('word_id', 'post_id', 'title_match'), ), USERS_TABLE => array( 'username_clean' => array('username_clean'), @@ -573,6 +595,18 @@ foreach ($database_update_info as $version => $schema_changes) } } } + + // Add indexes? + if (!empty($schema_changes['add_index'])) + { + foreach ($schema_changes['add_index'] as $table => $index_array) + { + foreach ($index_array as $index_name => $column) + { + sql_create_index($dbms, $index_name, $table, $column); + } + } + } } _write_result($no_updates, $errored, $error_ary); @@ -703,6 +737,48 @@ if (version_compare($current_version, '3.0.b4', '<=')) $no_updates = false; } +if (version_compare($current_version, '3.0.b6', '<=')) +{ + if ($config['fulltext_native_common_thres'] == 20) + { + set_config('fulltext_native_common_thres', '5'); + } + + $sql = 'SELECT m.word_id, COUNT(m.word_id) as word_count + FROM ' . SEARCH_WORDMATCH_TABLE . ' m, ' . SEARCH_WORDLIST_TABLE . ' w + WHERE m.word_id = w.word_id + AND w.word_common = 0 + GROUP BY m.word_id + ORDER BY word_count ASC'; + $result = $db->sql_query($sql); + + $value = 0; + $sql_in = array(); + while ($row = $db->sql_fetchrow($result)) + { + if ($value != $row['word_count'] && $value != 0 || sizeof($sql_in) > 500) + { + $sql = 'UPDATE ' . SEARCH_WORDLIST_TABLE . ' + SET word_count = ' . $value . ' + WHERE ' . $db->sql_in_set('word_id', $sql_in); + $db->sql_query($sql); + $sql_in = array(); + } + $value = $row['word_count']; + $sql_in[] = $row['word_id']; + } + + if (sizeof($sql_in)) + { + $sql = 'UPDATE ' . SEARCH_WORDLIST_TABLE . ' + SET word_count = ' . $value . ' + WHERE ' . $db->sql_in_set('word_id', $sql_in); + $db->sql_query($sql); + } + unset($sql_in); + $no_updates = false; +} + _write_result($no_updates, $errored, $error_ary); $error_ary = array(); @@ -1270,6 +1346,30 @@ function sql_create_unique_index($dbms, $index_name, $table_name, $column) } } +function sql_create_index($dbms, $index_name, $table_name, $column) +{ + global $dbms_type_map, $db; + global $errored, $error_ary; + + switch ($dbms) + { + case 'firebird': + case 'postgres': + case 'mysql_40': + case 'mysql_41': + case 'oracle': + case 'sqlite': + $sql = 'CREATE INDEX ' . $index_name . ' ON ' . $table_name . '(' . implode(', ', $column) . ')'; + _sql($sql, $errored, $error_ary); + break; + + case 'mssql': + $sql = 'CREATE INDEX ' . $index_name . ' ON ' . $table_name . '(' . implode(', ', $column) . ') ON [PRIMARY]'; + _sql($sql, $errored, $error_ary); + break; + } +} + /** * Change column type (not name!) */ diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index 7b9020371c..125c5c3fd5 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -202,7 +202,12 @@ class install_update extends module { $lang = array(); include($this->new_location . 'language/en/install.php'); - $user->lang = array_merge($user->lang, $lang); + // only add new keys to user's language in english + $new_keys = array_diff(array_keys($lang), array_keys($user->lang)); + foreach ($new_keys as $i => $new_key) + { + $user->lang[$new_key] = $lang[$new_key]; + } } } diff --git a/phpBB/install/schemas/firebird_schema.sql b/phpBB/install/schemas/firebird_schema.sql index 00df42ac39..2e3ab48a97 100644 --- a/phpBB/install/schemas/firebird_schema.sql +++ b/phpBB/install/schemas/firebird_schema.sql @@ -54,6 +54,7 @@ CREATE TABLE phpbb_acl_groups ( CREATE INDEX phpbb_acl_groups_group_id ON phpbb_acl_groups(group_id);; CREATE INDEX phpbb_acl_groups_auth_opt_id ON phpbb_acl_groups(auth_option_id);; +CREATE INDEX phpbb_acl_groups_auth_role_id ON phpbb_acl_groups(auth_role_id);; # Table: 'phpbb_acl_options' CREATE TABLE phpbb_acl_options ( @@ -113,6 +114,7 @@ CREATE TABLE phpbb_acl_roles_data ( ALTER TABLE phpbb_acl_roles_data ADD PRIMARY KEY (role_id, auth_option_id);; +CREATE INDEX phpbb_acl_roles_data_auth_option_id ON phpbb_acl_roles_data(auth_option_id);; # Table: 'phpbb_acl_users' CREATE TABLE phpbb_acl_users ( @@ -125,6 +127,7 @@ CREATE TABLE phpbb_acl_users ( CREATE INDEX phpbb_acl_users_user_id ON phpbb_acl_users(user_id);; CREATE INDEX phpbb_acl_users_auth_option_id ON phpbb_acl_users(auth_option_id);; +CREATE INDEX phpbb_acl_users_auth_role_id ON phpbb_acl_users(auth_role_id);; # Table: 'phpbb_banlist' CREATE TABLE phpbb_banlist ( @@ -924,12 +927,14 @@ ALTER TABLE phpbb_search_results ADD PRIMARY KEY (search_key);; CREATE TABLE phpbb_search_wordlist ( word_id INTEGER NOT NULL, word_text VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, - word_common INTEGER DEFAULT 0 NOT NULL + word_common INTEGER DEFAULT 0 NOT NULL, + word_count INTEGER DEFAULT 0 NOT NULL );; ALTER TABLE phpbb_search_wordlist ADD PRIMARY KEY (word_id);; CREATE UNIQUE INDEX phpbb_search_wordlist_wrd_txt ON phpbb_search_wordlist(word_text);; +CREATE INDEX phpbb_search_wordlist_wrd_cnt ON phpbb_search_wordlist(word_count);; CREATE GENERATOR phpbb_search_wordlist_gen;; SET GENERATOR phpbb_search_wordlist_gen TO 0;; diff --git a/phpBB/install/schemas/mssql_schema.sql b/phpBB/install/schemas/mssql_schema.sql index 8ef4c97c0d..3fa46ff7dd 100644 --- a/phpBB/install/schemas/mssql_schema.sql +++ b/phpBB/install/schemas/mssql_schema.sql @@ -71,6 +71,9 @@ GO CREATE INDEX [auth_opt_id] ON [phpbb_acl_groups]([auth_option_id]) ON [PRIMARY] GO +CREATE INDEX [auth_role_id] ON [phpbb_acl_groups]([auth_role_id]) ON [PRIMARY] +GO + /* Table: 'phpbb_acl_options' @@ -139,6 +142,9 @@ ALTER TABLE [phpbb_acl_roles_data] WITH NOCHECK ADD ) ON [PRIMARY] GO +CREATE INDEX [auth_option_id] ON [phpbb_acl_roles_data]([auth_option_id]) ON [PRIMARY] +GO + /* Table: 'phpbb_acl_users' @@ -158,6 +164,9 @@ GO CREATE INDEX [auth_option_id] ON [phpbb_acl_users]([auth_option_id]) ON [PRIMARY] GO +CREATE INDEX [auth_role_id] ON [phpbb_acl_users]([auth_role_id]) ON [PRIMARY] +GO + /* Table: 'phpbb_banlist' @@ -1098,7 +1107,8 @@ GO CREATE TABLE [phpbb_search_wordlist] ( [word_id] [int] IDENTITY (1, 1) NOT NULL , [word_text] [varchar] (255) DEFAULT ('') NOT NULL , - [word_common] [int] DEFAULT (0) NOT NULL + [word_common] [int] DEFAULT (0) NOT NULL , + [word_count] [int] DEFAULT (0) NOT NULL ) ON [PRIMARY] GO @@ -1112,6 +1122,9 @@ GO CREATE UNIQUE INDEX [wrd_txt] ON [phpbb_search_wordlist]([word_text]) ON [PRIMARY] GO +CREATE INDEX [wrd_cnt] ON [phpbb_search_wordlist]([word_count]) ON [PRIMARY] +GO + /* Table: 'phpbb_search_wordmatch' diff --git a/phpBB/install/schemas/mysql_40_schema.sql b/phpBB/install/schemas/mysql_40_schema.sql index 50b980df89..a1fec9867d 100644 --- a/phpBB/install/schemas/mysql_40_schema.sql +++ b/phpBB/install/schemas/mysql_40_schema.sql @@ -38,7 +38,8 @@ CREATE TABLE phpbb_acl_groups ( auth_role_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, auth_setting tinyint(2) DEFAULT '0' NOT NULL, KEY group_id (group_id), - KEY auth_opt_id (auth_option_id) + KEY auth_opt_id (auth_option_id), + KEY auth_role_id (auth_role_id) ); @@ -72,7 +73,8 @@ CREATE TABLE phpbb_acl_roles_data ( role_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, auth_option_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, auth_setting tinyint(2) DEFAULT '0' NOT NULL, - PRIMARY KEY (role_id, auth_option_id) + PRIMARY KEY (role_id, auth_option_id), + KEY auth_option_id (auth_option_id) ); @@ -84,7 +86,8 @@ CREATE TABLE phpbb_acl_users ( auth_role_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, auth_setting tinyint(2) DEFAULT '0' NOT NULL, KEY user_id (user_id), - KEY auth_option_id (auth_option_id) + KEY auth_option_id (auth_option_id), + KEY auth_role_id (auth_role_id) ); @@ -638,8 +641,10 @@ CREATE TABLE phpbb_search_wordlist ( word_id mediumint(8) UNSIGNED NOT NULL auto_increment, word_text blob NOT NULL, word_common tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + word_count mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, PRIMARY KEY (word_id), - UNIQUE wrd_txt (word_text(255)) + UNIQUE wrd_txt (word_text(255)), + KEY wrd_cnt (word_count) ); diff --git a/phpBB/install/schemas/mysql_41_schema.sql b/phpBB/install/schemas/mysql_41_schema.sql index 5362dbfdc5..a2785867be 100644 --- a/phpBB/install/schemas/mysql_41_schema.sql +++ b/phpBB/install/schemas/mysql_41_schema.sql @@ -38,7 +38,8 @@ CREATE TABLE phpbb_acl_groups ( auth_role_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, auth_setting tinyint(2) DEFAULT '0' NOT NULL, KEY group_id (group_id), - KEY auth_opt_id (auth_option_id) + KEY auth_opt_id (auth_option_id), + KEY auth_role_id (auth_role_id) ) CHARACTER SET `utf8` COLLATE `utf8_bin`; @@ -72,7 +73,8 @@ CREATE TABLE phpbb_acl_roles_data ( role_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, auth_option_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, auth_setting tinyint(2) DEFAULT '0' NOT NULL, - PRIMARY KEY (role_id, auth_option_id) + PRIMARY KEY (role_id, auth_option_id), + KEY auth_option_id (auth_option_id) ) CHARACTER SET `utf8` COLLATE `utf8_bin`; @@ -84,7 +86,8 @@ CREATE TABLE phpbb_acl_users ( auth_role_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, auth_setting tinyint(2) DEFAULT '0' NOT NULL, KEY user_id (user_id), - KEY auth_option_id (auth_option_id) + KEY auth_option_id (auth_option_id), + KEY auth_role_id (auth_role_id) ) CHARACTER SET `utf8` COLLATE `utf8_bin`; @@ -638,8 +641,10 @@ CREATE TABLE phpbb_search_wordlist ( word_id mediumint(8) UNSIGNED NOT NULL auto_increment, word_text varchar(255) DEFAULT '' NOT NULL, word_common tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + word_count mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, PRIMARY KEY (word_id), - UNIQUE wrd_txt (word_text) + UNIQUE wrd_txt (word_text), + KEY wrd_cnt (word_count) ) CHARACTER SET `utf8` COLLATE `utf8_bin`; diff --git a/phpBB/install/schemas/oracle_schema.sql b/phpBB/install/schemas/oracle_schema.sql index b6d8bd7ac1..a2e3532e2b 100644 --- a/phpBB/install/schemas/oracle_schema.sql +++ b/phpBB/install/schemas/oracle_schema.sql @@ -108,6 +108,8 @@ CREATE INDEX phpbb_acl_groups_group_id ON phpbb_acl_groups (group_id) / CREATE INDEX phpbb_acl_groups_auth_opt_id ON phpbb_acl_groups (auth_option_id) / +CREATE INDEX phpbb_acl_groups_auth_role_id ON phpbb_acl_groups (auth_role_id) +/ /* Table: 'phpbb_acl_options' @@ -186,6 +188,8 @@ CREATE TABLE phpbb_acl_roles_data ( ) / +CREATE INDEX phpbb_acl_roles_data_auth_option_id ON phpbb_acl_roles_data (auth_option_id) +/ /* Table: 'phpbb_acl_users' @@ -203,6 +207,8 @@ CREATE INDEX phpbb_acl_users_user_id ON phpbb_acl_users (user_id) / CREATE INDEX phpbb_acl_users_auth_option_id ON phpbb_acl_users (auth_option_id) / +CREATE INDEX phpbb_acl_users_auth_role_id ON phpbb_acl_users (auth_role_id) +/ /* Table: 'phpbb_banlist' @@ -1232,11 +1238,14 @@ CREATE TABLE phpbb_search_wordlist ( word_id number(8) NOT NULL, word_text varchar2(765) DEFAULT '' , word_common number(1) DEFAULT '0' NOT NULL, + word_count number(8) DEFAULT '0' NOT NULL, CONSTRAINT pk_phpbb_search_wordlist PRIMARY KEY (word_id), CONSTRAINT u_phpbb_wrd_txt UNIQUE (word_text) ) / +CREATE INDEX phpbb_search_wordlist_wrd_cnt ON phpbb_search_wordlist (word_count) +/ CREATE SEQUENCE phpbb_search_wordlist_seq / diff --git a/phpBB/install/schemas/postgres_schema.sql b/phpBB/install/schemas/postgres_schema.sql index 663f26cbed..910ae4f022 100644 --- a/phpBB/install/schemas/postgres_schema.sql +++ b/phpBB/install/schemas/postgres_schema.sql @@ -125,6 +125,7 @@ CREATE TABLE phpbb_acl_groups ( CREATE INDEX phpbb_acl_groups_group_id ON phpbb_acl_groups (group_id); CREATE INDEX phpbb_acl_groups_auth_opt_id ON phpbb_acl_groups (auth_option_id); +CREATE INDEX phpbb_acl_groups_auth_role_id ON phpbb_acl_groups (auth_role_id); /* Table: 'phpbb_acl_options' @@ -169,6 +170,7 @@ CREATE TABLE phpbb_acl_roles_data ( PRIMARY KEY (role_id, auth_option_id) ); +CREATE INDEX phpbb_acl_roles_data_auth_option_id ON phpbb_acl_roles_data (auth_option_id); /* Table: 'phpbb_acl_users' @@ -183,6 +185,7 @@ CREATE TABLE phpbb_acl_users ( CREATE INDEX phpbb_acl_users_user_id ON phpbb_acl_users (user_id); CREATE INDEX phpbb_acl_users_auth_option_id ON phpbb_acl_users (auth_option_id); +CREATE INDEX phpbb_acl_users_auth_role_id ON phpbb_acl_users (auth_role_id); /* Table: 'phpbb_banlist' @@ -848,10 +851,12 @@ CREATE TABLE phpbb_search_wordlist ( word_id INT4 DEFAULT nextval('phpbb_search_wordlist_seq'), word_text varchar(255) DEFAULT '' NOT NULL, word_common INT2 DEFAULT '0' NOT NULL CHECK (word_common >= 0), + word_count INT4 DEFAULT '0' NOT NULL CHECK (word_count >= 0), PRIMARY KEY (word_id) ); CREATE UNIQUE INDEX phpbb_search_wordlist_wrd_txt ON phpbb_search_wordlist (word_text); +CREATE INDEX phpbb_search_wordlist_wrd_cnt ON phpbb_search_wordlist (word_count); /* Table: 'phpbb_search_wordmatch' diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql index bdb603764c..9d9a26e3f2 100644 --- a/phpBB/install/schemas/schema_data.sql +++ b/phpBB/install/schemas/schema_data.sql @@ -90,7 +90,7 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('forwarded_for_chec INSERT INTO phpbb_config (config_name, config_value) VALUES ('full_folder_action', '2'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('fulltext_mysql_max_word_len', '254'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('fulltext_mysql_min_word_len', '4'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('fulltext_native_common_thres', '20'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('fulltext_native_common_thres', '5'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('fulltext_native_load_upd', '1'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('fulltext_native_max_chars', '14'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('fulltext_native_min_chars', '3'); diff --git a/phpBB/install/schemas/sqlite_schema.sql b/phpBB/install/schemas/sqlite_schema.sql index a8620234b3..115c69376b 100644 --- a/phpBB/install/schemas/sqlite_schema.sql +++ b/phpBB/install/schemas/sqlite_schema.sql @@ -42,6 +42,7 @@ CREATE TABLE phpbb_acl_groups ( CREATE INDEX phpbb_acl_groups_group_id ON phpbb_acl_groups (group_id); CREATE INDEX phpbb_acl_groups_auth_opt_id ON phpbb_acl_groups (auth_option_id); +CREATE INDEX phpbb_acl_groups_auth_role_id ON phpbb_acl_groups (auth_role_id); # Table: 'phpbb_acl_options' CREATE TABLE phpbb_acl_options ( @@ -74,6 +75,7 @@ CREATE TABLE phpbb_acl_roles_data ( PRIMARY KEY (role_id, auth_option_id) ); +CREATE INDEX phpbb_acl_roles_data_auth_option_id ON phpbb_acl_roles_data (auth_option_id); # Table: 'phpbb_acl_users' CREATE TABLE phpbb_acl_users ( @@ -86,6 +88,7 @@ CREATE TABLE phpbb_acl_users ( CREATE INDEX phpbb_acl_users_user_id ON phpbb_acl_users (user_id); CREATE INDEX phpbb_acl_users_auth_option_id ON phpbb_acl_users (auth_option_id); +CREATE INDEX phpbb_acl_users_auth_role_id ON phpbb_acl_users (auth_role_id); # Table: 'phpbb_banlist' CREATE TABLE phpbb_banlist ( @@ -616,10 +619,12 @@ CREATE TABLE phpbb_search_results ( CREATE TABLE phpbb_search_wordlist ( word_id INTEGER PRIMARY KEY NOT NULL , word_text varchar(255) NOT NULL DEFAULT '', - word_common INTEGER UNSIGNED NOT NULL DEFAULT '0' + word_common INTEGER UNSIGNED NOT NULL DEFAULT '0', + word_count INTEGER UNSIGNED NOT NULL DEFAULT '0' ); CREATE UNIQUE INDEX phpbb_search_wordlist_wrd_txt ON phpbb_search_wordlist (word_text); +CREATE INDEX phpbb_search_wordlist_wrd_cnt ON phpbb_search_wordlist (word_count); # Table: 'phpbb_search_wordmatch' CREATE TABLE phpbb_search_wordmatch ( |