1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-05 00:07:44 +02:00

- 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
This commit is contained in:
Nils Adermann
2007-03-13 22:00:55 +00:00
parent 5e06885ea4
commit ce8b00801e
13 changed files with 298 additions and 63 deletions

View File

@@ -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!)
*/

View File

@@ -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];
}
}
}

View File

@@ -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;;

View File

@@ -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'

View File

@@ -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)
);

View File

@@ -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`;

View File

@@ -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
/

View File

@@ -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'

View File

@@ -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');

View File

@@ -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 (