1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-30 21:40:43 +02:00

[ticket/11103] Move is_enabled to a separate table for better performance

PHPBB3-11103
This commit is contained in:
Nathan Guse
2012-12-15 19:18:26 -06:00
parent c6f138ff12
commit f47e51d6de
17 changed files with 187 additions and 101 deletions

View File

@@ -93,6 +93,10 @@ if (!defined('LOGIN_ATTEMPT_TABLE'))
{
define('LOGIN_ATTEMPT_TABLE', $table_prefix . 'login_attempts');
}
if (!defined('NOTIFICATION_TYPES_TABLE'))
{
define('NOTIFICATION_TYPES_TABLE', $table_prefix . 'notification_types');
}
if (!defined('NOTIFICATIONS_TABLE'))
{
define('NOTIFICATIONS_TABLE', $table_prefix . 'notifications');
@@ -1179,6 +1183,13 @@ function database_update_info()
'ext_name' => array('UNIQUE', 'ext_name'),
),
),
NOTIFICATION_TYPES_TABLE => array(
'COLUMNS' => array(
'notification_type' => array('VCHAR:255', ''),
'notification_type_enabled' => array('BOOL', 1),
),
'PRIMARY_KEY' => array('notification_type', 'notification_type_enabled'),
),
NOTIFICATIONS_TABLE => array(
'COLUMNS' => array(
'notification_id' => array('UINT', NULL, 'auto_increment'),

View File

@@ -618,6 +618,15 @@ BEGIN
END;;
# Table: 'phpbb_notification_types'
CREATE TABLE phpbb_notification_types (
notification_type VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL,
notification_type_enabled INTEGER DEFAULT 1 NOT NULL
);;
ALTER TABLE phpbb_notification_types ADD PRIMARY KEY (notification_type, notification_type_enabled);;
# Table: 'phpbb_notifications'
CREATE TABLE phpbb_notifications (
notification_id INTEGER NOT NULL,
@@ -626,7 +635,6 @@ CREATE TABLE phpbb_notifications (
item_parent_id INTEGER DEFAULT 0 NOT NULL,
user_id INTEGER DEFAULT 0 NOT NULL,
unread INTEGER DEFAULT 1 NOT NULL,
is_enabled INTEGER DEFAULT 1 NOT NULL,
time INTEGER DEFAULT 1 NOT NULL,
data BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL
);;
@@ -1243,9 +1251,6 @@ CREATE TABLE phpbb_user_notifications (
ALTER TABLE phpbb_user_notifications ADD PRIMARY KEY (item_type, item_id, user_id, method);;
CREATE INDEX phpbb_user_notifications_it ON phpbb_user_notifications(item_type);;
CREATE INDEX phpbb_user_notifications_uid ON phpbb_user_notifications(user_id);;
CREATE INDEX phpbb_user_notifications_no ON phpbb_user_notifications(notify);;
# Table: 'phpbb_user_group'
CREATE TABLE phpbb_user_group (

View File

@@ -751,6 +751,24 @@ CREATE INDEX [class_left_id] ON [phpbb_modules]([module_class], [left_id]) ON [
GO
/*
Table: 'phpbb_notification_types'
*/
CREATE TABLE [phpbb_notification_types] (
[notification_type] [varchar] (255) DEFAULT ('') NOT NULL ,
[notification_type_enabled] [int] DEFAULT (1) NOT NULL
) ON [PRIMARY]
GO
ALTER TABLE [phpbb_notification_types] WITH NOCHECK ADD
CONSTRAINT [PK_phpbb_notification_types] PRIMARY KEY CLUSTERED
(
[notification_type],
[notification_type_enabled]
) ON [PRIMARY]
GO
/*
Table: 'phpbb_notifications'
*/
@@ -761,7 +779,6 @@ CREATE TABLE [phpbb_notifications] (
[item_parent_id] [int] DEFAULT (0) NOT NULL ,
[user_id] [int] DEFAULT (0) NOT NULL ,
[unread] [int] DEFAULT (1) NOT NULL ,
[is_enabled] [int] DEFAULT (1) NOT NULL ,
[time] [int] DEFAULT (1) NOT NULL ,
[data] [varchar] (4000) DEFAULT ('') NOT NULL
) ON [PRIMARY]
@@ -1528,15 +1545,6 @@ ALTER TABLE [phpbb_user_notifications] WITH NOCHECK ADD
) ON [PRIMARY]
GO
CREATE INDEX [it] ON [phpbb_user_notifications]([item_type]) ON [PRIMARY]
GO
CREATE INDEX [uid] ON [phpbb_user_notifications]([user_id]) ON [PRIMARY]
GO
CREATE INDEX [no] ON [phpbb_user_notifications]([notify]) ON [PRIMARY]
GO
/*
Table: 'phpbb_user_group'

View File

@@ -430,6 +430,14 @@ CREATE TABLE phpbb_modules (
);
# Table: 'phpbb_notification_types'
CREATE TABLE phpbb_notification_types (
notification_type varbinary(255) DEFAULT '' NOT NULL,
notification_type_enabled tinyint(1) UNSIGNED DEFAULT '1' NOT NULL,
PRIMARY KEY (notification_type, notification_type_enabled)
);
# Table: 'phpbb_notifications'
CREATE TABLE phpbb_notifications (
notification_id mediumint(8) UNSIGNED NOT NULL auto_increment,
@@ -438,7 +446,6 @@ CREATE TABLE phpbb_notifications (
item_parent_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
unread tinyint(1) UNSIGNED DEFAULT '1' NOT NULL,
is_enabled tinyint(1) UNSIGNED DEFAULT '1' NOT NULL,
time int(11) UNSIGNED DEFAULT '1' NOT NULL,
data blob NOT NULL,
PRIMARY KEY (notification_id),
@@ -875,10 +882,7 @@ CREATE TABLE phpbb_user_notifications (
user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
method varbinary(255) DEFAULT '' NOT NULL,
notify tinyint(1) UNSIGNED DEFAULT '1' NOT NULL,
PRIMARY KEY (item_type, item_id, user_id, method),
KEY it (item_type),
KEY uid (user_id),
KEY no (notify)
PRIMARY KEY (item_type, item_id, user_id, method)
);

View File

@@ -430,6 +430,14 @@ CREATE TABLE phpbb_modules (
) CHARACTER SET `utf8` COLLATE `utf8_bin`;
# Table: 'phpbb_notification_types'
CREATE TABLE phpbb_notification_types (
notification_type varchar(255) DEFAULT '' NOT NULL,
notification_type_enabled tinyint(1) UNSIGNED DEFAULT '1' NOT NULL,
PRIMARY KEY (notification_type, notification_type_enabled)
) CHARACTER SET `utf8` COLLATE `utf8_bin`;
# Table: 'phpbb_notifications'
CREATE TABLE phpbb_notifications (
notification_id mediumint(8) UNSIGNED NOT NULL auto_increment,
@@ -438,7 +446,6 @@ CREATE TABLE phpbb_notifications (
item_parent_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
unread tinyint(1) UNSIGNED DEFAULT '1' NOT NULL,
is_enabled tinyint(1) UNSIGNED DEFAULT '1' NOT NULL,
time int(11) UNSIGNED DEFAULT '1' NOT NULL,
data text NOT NULL,
PRIMARY KEY (notification_id),
@@ -875,10 +882,7 @@ CREATE TABLE phpbb_user_notifications (
user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
method varchar(255) DEFAULT '' NOT NULL,
notify tinyint(1) UNSIGNED DEFAULT '1' NOT NULL,
PRIMARY KEY (item_type, item_id, user_id, method),
KEY it (item_type),
KEY uid (user_id),
KEY no (notify)
PRIMARY KEY (item_type, item_id, user_id, method)
) CHARACTER SET `utf8` COLLATE `utf8_bin`;

View File

@@ -840,6 +840,17 @@ END;
/
/*
Table: 'phpbb_notification_types'
*/
CREATE TABLE phpbb_notification_types (
notification_type varchar2(255) DEFAULT '' ,
notification_type_enabled number(1) DEFAULT '1' NOT NULL,
CONSTRAINT pk_phpbb_notification_types PRIMARY KEY (notification_type, notification_type_enabled)
)
/
/*
Table: 'phpbb_notifications'
*/
@@ -850,7 +861,6 @@ CREATE TABLE phpbb_notifications (
item_parent_id number(8) DEFAULT '0' NOT NULL,
user_id number(8) DEFAULT '0' NOT NULL,
unread number(1) DEFAULT '1' NOT NULL,
is_enabled number(1) DEFAULT '1' NOT NULL,
time number(11) DEFAULT '1' NOT NULL,
data clob DEFAULT '' ,
CONSTRAINT pk_phpbb_notifications PRIMARY KEY (notification_id)
@@ -1642,12 +1652,6 @@ CREATE TABLE phpbb_user_notifications (
)
/
CREATE INDEX phpbb_user_notifications_it ON phpbb_user_notifications (item_type)
/
CREATE INDEX phpbb_user_notifications_uid ON phpbb_user_notifications (user_id)
/
CREATE INDEX phpbb_user_notifications_no ON phpbb_user_notifications (notify)
/
/*
Table: 'phpbb_user_group'

View File

@@ -596,6 +596,16 @@ CREATE INDEX phpbb_modules_left_right_id ON phpbb_modules (left_id, right_id);
CREATE INDEX phpbb_modules_module_enabled ON phpbb_modules (module_enabled);
CREATE INDEX phpbb_modules_class_left_id ON phpbb_modules (module_class, left_id);
/*
Table: 'phpbb_notification_types'
*/
CREATE TABLE phpbb_notification_types (
notification_type varchar(255) DEFAULT '' NOT NULL,
notification_type_enabled INT2 DEFAULT '1' NOT NULL CHECK (notification_type_enabled >= 0),
PRIMARY KEY (notification_type, notification_type_enabled)
);
/*
Table: 'phpbb_notifications'
*/
@@ -608,7 +618,6 @@ CREATE TABLE phpbb_notifications (
item_parent_id INT4 DEFAULT '0' NOT NULL CHECK (item_parent_id >= 0),
user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0),
unread INT2 DEFAULT '1' NOT NULL CHECK (unread >= 0),
is_enabled INT2 DEFAULT '1' NOT NULL CHECK (is_enabled >= 0),
time INT4 DEFAULT '1' NOT NULL CHECK (time >= 0),
data varchar(4000) DEFAULT '' NOT NULL,
PRIMARY KEY (notification_id)
@@ -1128,9 +1137,6 @@ CREATE TABLE phpbb_user_notifications (
PRIMARY KEY (item_type, item_id, user_id, method)
);
CREATE INDEX phpbb_user_notifications_it ON phpbb_user_notifications (item_type);
CREATE INDEX phpbb_user_notifications_uid ON phpbb_user_notifications (user_id);
CREATE INDEX phpbb_user_notifications_no ON phpbb_user_notifications (notify);
/*
Table: 'phpbb_user_group'

View File

@@ -417,6 +417,14 @@ CREATE INDEX phpbb_modules_left_right_id ON phpbb_modules (left_id, right_id);
CREATE INDEX phpbb_modules_module_enabled ON phpbb_modules (module_enabled);
CREATE INDEX phpbb_modules_class_left_id ON phpbb_modules (module_class, left_id);
# Table: 'phpbb_notification_types'
CREATE TABLE phpbb_notification_types (
notification_type varchar(255) NOT NULL DEFAULT '',
notification_type_enabled INTEGER UNSIGNED NOT NULL DEFAULT '1',
PRIMARY KEY (notification_type, notification_type_enabled)
);
# Table: 'phpbb_notifications'
CREATE TABLE phpbb_notifications (
notification_id INTEGER PRIMARY KEY NOT NULL ,
@@ -425,7 +433,6 @@ CREATE TABLE phpbb_notifications (
item_parent_id INTEGER UNSIGNED NOT NULL DEFAULT '0',
user_id INTEGER UNSIGNED NOT NULL DEFAULT '0',
unread INTEGER UNSIGNED NOT NULL DEFAULT '1',
is_enabled INTEGER UNSIGNED NOT NULL DEFAULT '1',
time INTEGER UNSIGNED NOT NULL DEFAULT '1',
data text(65535) NOT NULL DEFAULT ''
);
@@ -851,9 +858,6 @@ CREATE TABLE phpbb_user_notifications (
PRIMARY KEY (item_type, item_id, user_id, method)
);
CREATE INDEX phpbb_user_notifications_it ON phpbb_user_notifications (item_type);
CREATE INDEX phpbb_user_notifications_uid ON phpbb_user_notifications (user_id);
CREATE INDEX phpbb_user_notifications_no ON phpbb_user_notifications (notify);
# Table: 'phpbb_user_group'
CREATE TABLE phpbb_user_group (