Indexes on faux foreign keys and often used fields, one more set and version bump to come.
This commit is contained in:
@@ -843,6 +843,47 @@ function main_upgrade($oldversion=0) {
|
||||
execute_sql("UPDATE {$CFG->prefix}course SET lang = 'mi_nt' WHERE lang = 'ma_nt'");
|
||||
}
|
||||
|
||||
if ($oldversion < 2004083128) { // add indexes.
|
||||
execute_sql(" ALTER TABLE `{$CFG->prefix}user` ADD INDEX user_idnumber (idnumber) ");
|
||||
execute_sql(" ALTER TABLE `{$CFG->prefix}user` ADD INDEX user_auth (auth) ");
|
||||
}
|
||||
|
||||
if ($oldversion < 2004083128) { // add indexes.
|
||||
execute_sql(" ALTER TABLE `{$CFG->prefix}course` ADD INDEX idnumber (idnumber) ");
|
||||
execute_sql(" ALTER TABLE `{$CFG->prefix}course` ADD INDEX shortname (shortname) ");
|
||||
execute_sql(" ALTER TABLE `{$CFG->prefix}user_students` ADD INDEX userid (userid) ");
|
||||
execute_sql(" ALTER TABLE `{$CFG->prefix}user_teachers` ADD INDEX userid (userid) ");
|
||||
}
|
||||
|
||||
if ($oldversion < 2004083128) {// add an index to event for timestart and timeduration
|
||||
modify_database('','ALTER TABLE prefix_event ADD INDEX timestart (timestart);');
|
||||
modify_database('','ALTER TABLE prefix_event ADD INDEX timeduration (timeduration);');
|
||||
}
|
||||
|
||||
if ($oldversion < 2004083128) { //add indexes on modules and course_modules
|
||||
modify_database('','ALTER TABLE prefix_course_modules add key visible(visible);');
|
||||
modify_database('','ALTER TABLE prefix_course_modules add key course(course);');
|
||||
modify_database('','ALTER TABLE prefix_course_modules add key module(module);');
|
||||
modify_database('','ALTER TABLE prefix_course_modules add key instance (instance);');
|
||||
modify_database('','ALTER TABLE prefix_course_modules add key deleted (deleted);');
|
||||
modify_database('','ALTER TABLE prefix_modules add key name(name);');
|
||||
}
|
||||
|
||||
|
||||
if ($oldversion < 2004083128) { // add an index on the groups_members table
|
||||
modify_database('','ALTER TABLE prefix_groups_members ADD INDEX userid (userid);');
|
||||
}
|
||||
|
||||
if ($oldversion < 2004083128) { // add an index on user students timeaccess (used for sorting)
|
||||
modify_database('','ALTER TABLE prefix_user_students ADD INDEX timeaccess (timeaccess);');
|
||||
}
|
||||
|
||||
if ($oldversion < 2004083128) {
|
||||
modify_database('','ALTER TABLE prefix_scale ADD INDEX courseid (courseid);');
|
||||
modify_database('','ALTER TABLE prefix_user_admins ADD INDEX userid (userid);');
|
||||
modify_database('','ALTER TABLE prefix_user_coursecreators ADD INDEX userid (userid);');
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
+30
-11
@@ -61,7 +61,9 @@ CREATE TABLE `prefix_course` (
|
||||
`timecreated` int(10) unsigned NOT NULL default '0',
|
||||
`timemodified` int(10) unsigned NOT NULL default '0',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `category` (`category`)
|
||||
KEY `category` (`category`),
|
||||
KEY `idnumber` (`idnumber`),
|
||||
KEY `shortname` (`shortname`)
|
||||
) TYPE=MyISAM;
|
||||
# --------------------------------------------------------
|
||||
|
||||
@@ -117,7 +119,12 @@ CREATE TABLE `prefix_course_modules` (
|
||||
`visible` tinyint(1) NOT NULL default '1',
|
||||
`groupmode` tinyint(4) NOT NULL default '0',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `id` (`id`)
|
||||
UNIQUE KEY `id` (`id`),
|
||||
KEY `visible` (`visible`),
|
||||
KEY `course` (`course`),
|
||||
KEY `module` (`module`),
|
||||
KEY `instance` (`instance`),
|
||||
KEY `deleted` (`deleted`)
|
||||
) TYPE=MyISAM;
|
||||
# --------------------------------------------------------
|
||||
|
||||
@@ -159,7 +166,9 @@ CREATE TABLE `prefix_event` (
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `id` (`id`),
|
||||
KEY `courseid` (`courseid`),
|
||||
KEY `userid` (`userid`)
|
||||
KEY `userid` (`userid`),
|
||||
KEY `timestart` (`timestart`),
|
||||
KEY `timeduration` (`timeduration`)
|
||||
) TYPE=MyISAM COMMENT='For everything with a time associated to it';
|
||||
# --------------------------------------------------------
|
||||
|
||||
@@ -227,7 +236,8 @@ CREATE TABLE `prefix_groups_members` (
|
||||
`timeadded` int(10) unsigned NOT NULL default '0',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `id` (`id`),
|
||||
KEY `groupid` (`groupid`)
|
||||
KEY `groupid` (`groupid`),
|
||||
KEY `userid` (`userid`)
|
||||
) TYPE=MyISAM COMMENT='Lists memberships of users to groups';
|
||||
# --------------------------------------------------------
|
||||
|
||||
@@ -279,7 +289,8 @@ CREATE TABLE `prefix_modules` (
|
||||
`search` varchar(255) NOT NULL default '',
|
||||
`visible` tinyint(1) NOT NULL default '1',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `id` (`id`)
|
||||
UNIQUE KEY `id` (`id`),
|
||||
KEY `name` (`name`)
|
||||
) TYPE=MyISAM;
|
||||
# --------------------------------------------------------
|
||||
|
||||
@@ -296,7 +307,8 @@ CREATE TABLE `prefix_scale` (
|
||||
`scale` text NOT NULL,
|
||||
`description` text NOT NULL,
|
||||
`timemodified` int(10) unsigned NOT NULL default '0',
|
||||
PRIMARY KEY (id)
|
||||
PRIMARY KEY (id),
|
||||
KEY `courseid` (`courseid`)
|
||||
) TYPE=MyISAM COMMENT='Defines grading scales';
|
||||
# --------------------------------------------------------
|
||||
|
||||
@@ -344,7 +356,9 @@ CREATE TABLE `prefix_user` (
|
||||
`timemodified` int(10) unsigned NOT NULL default '0',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `id` (`id`),
|
||||
UNIQUE KEY `username` (`username`)
|
||||
UNIQUE KEY `username` (`username`),
|
||||
KEY `user_idnumber` (`idnumber`),
|
||||
KEY `user_auth` (`auth`)
|
||||
) TYPE=MyISAM COMMENT='One record for each person';
|
||||
# --------------------------------------------------------
|
||||
|
||||
@@ -356,7 +370,8 @@ CREATE TABLE `prefix_user_admins` (
|
||||
`id` int(10) unsigned NOT NULL auto_increment,
|
||||
`userid` int(10) unsigned NOT NULL default '0',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `id` (`id`)
|
||||
UNIQUE KEY `id` (`id`),
|
||||
KEY `userid` (`userid`)
|
||||
) TYPE=MyISAM COMMENT='One record per administrator user';
|
||||
# --------------------------------------------------------
|
||||
|
||||
@@ -393,7 +408,9 @@ CREATE TABLE `prefix_user_students` (
|
||||
`timeaccess` int(10) unsigned NOT NULL default '0',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `id` (`id`),
|
||||
KEY `courseuserid` (course,userid)
|
||||
KEY `courseuserid` (course,userid),
|
||||
KEY `userid` (userid),
|
||||
KEY `timeaccess` (timeaccess)
|
||||
) TYPE=MyISAM;
|
||||
# --------------------------------------------------------
|
||||
|
||||
@@ -414,7 +431,8 @@ CREATE TABLE `prefix_user_teachers` (
|
||||
`timeaccess` int(10) unsigned NOT NULL default '0',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `id` (`id`),
|
||||
KEY `courseuserid` (course,userid)
|
||||
KEY `courseuserid` (course,userid),
|
||||
KEY `userid` (userid)
|
||||
) TYPE=MyISAM COMMENT='One record per teacher per course';
|
||||
|
||||
#
|
||||
@@ -425,7 +443,8 @@ CREATE TABLE `prefix_user_coursecreators` (
|
||||
`id` int(10) unsigned NOT NULL auto_increment,
|
||||
`userid` int(10) unsigned NOT NULL default '0',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `id` (`id`)
|
||||
UNIQUE KEY `id` (`id`),
|
||||
KEY `userid` (`userid`)
|
||||
) TYPE=MyISAM COMMENT='One record per course creator';
|
||||
|
||||
INSERT INTO prefix_log_display VALUES ('user', 'view', 'user', 'CONCAT(firstname," ",lastname)');
|
||||
|
||||
+42
-1
@@ -577,8 +577,49 @@ function main_upgrade($oldversion=0) {
|
||||
execute_sql("UPDATE {$CFG->prefix}course SET lang = 'mi_nt' WHERE lang = 'ma_nt'");
|
||||
}
|
||||
|
||||
return $result;
|
||||
if ($oldversion < 2004083128) { // add indexes.
|
||||
modify_database("", "CREATE INDEX prefix_user_idnumber_idx ON prefix_user (idnumber);");
|
||||
modify_database("", "CREATE INDEX prefix_user_auth_idx ON prefix_user (auth);");
|
||||
}
|
||||
|
||||
if ($oldversion < 2004083128) { // add indexes
|
||||
modify_database("","CREATE INDEX {$CFG->prefix}course_idnumber_idx ON {$CFG->prefix}course (idnumber);" );
|
||||
modify_database("","CREATE INDEX {$CFG->prefix}course_shortname_idx ON {$CFG->prefix}course (shortname);" );
|
||||
modify_database("","CREATE INDEX {$CFG->prefix}user_students_userid_idx ON {$CFG->prefix}user_students (userid);");
|
||||
modify_database("","CREATE INDEX {$CFG->prefix}user_teachers_userid_idx ON {$CFG->prefix}user_teachers (userid);");
|
||||
}
|
||||
|
||||
if ($oldversion < 2004083128) { // add an index to event for timestart and timeduration
|
||||
modify_database('','CREATE INDEX prefix_event_timestart_idx ON prefix_event (timestart);');
|
||||
modify_database('','CREATE INDEX prefix_event_timeduration_idx ON prefix_event (timeduration);');
|
||||
}
|
||||
|
||||
if ($oldversion < 2004083128) { //add indexes on modules and course_modules
|
||||
modify_database('','CREATE INDEX prefix_course_modules_visible_idx ON prefix_course_modules (visible);');
|
||||
modify_database('','CREATE INDEX prefix_course_modules_course_idx ON prefix_course_modules (course);');
|
||||
modify_database('','CREATE INDEX prefix_course_modules_module_idx ON prefix_course_modules (module);');
|
||||
modify_database('','CREATE INDEX prefix_course_modules_instance_idx ON prefix_course_modules (instance);');
|
||||
modify_database('','CREATE INDEX prefix_course_modules_deleted_idx ON prefix_course_modules (deleted);');
|
||||
modify_database('','CREATE INDEX prefix_modules_name_idx ON prefix_modules (name);');
|
||||
}
|
||||
|
||||
if ($oldversion < 2004083128) { // add an index on the groups_members table
|
||||
modify_database('','CREATE INDEX prefix_groups_members_userid_idx ON prefix_groups_members (userid);');
|
||||
}
|
||||
|
||||
|
||||
if ($oldversion < 2004083128) { // add an index on user students timeaccess (used for sorting)
|
||||
modify_database('','CREATE INDEX prefix_user_students_timeaccess_idx ON prefix_user_students (timeaccess);');
|
||||
}
|
||||
|
||||
if ($oldversion < 2004083128) {
|
||||
modify_database('','CREATE INDEX prefix_course_sections_coursesection_idx ON prefix_course_sections (course,section);');
|
||||
modify_database('','CREATE INDEX prefix_scale_courseid_idx ON prefix_scale (courseid);');
|
||||
modify_database('','CREATE INDEX prefix_user_admins_userid_idx ON prefix_user_admins (userid);');
|
||||
modify_database('','CREATE INDEX prefix_user_coursecreators_userid_idx ON prefix_user_coursecreators (userid);');
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
+29
-2
@@ -41,6 +41,8 @@ CREATE TABLE prefix_course (
|
||||
);
|
||||
|
||||
CREATE INDEX prefix_course_category_idx ON prefix_course (category);
|
||||
CREATE INDEX prefix_course_idnumber_idx ON prefix_course (idnumber);
|
||||
CREATE INDEX prefix_course_shortname_idx ON prefix_course (shortname);
|
||||
|
||||
CREATE TABLE prefix_course_categories (
|
||||
id SERIAL PRIMARY KEY,
|
||||
@@ -76,6 +78,12 @@ CREATE TABLE prefix_course_modules (
|
||||
groupmode integer NOT NULL default '0'
|
||||
);
|
||||
|
||||
CREATE INDEX prefix_course_modules_visible_idx ON prefix_course_modules (visible);
|
||||
CREATE INDEX prefix_course_modules_course_idx ON prefix_course_modules (course);
|
||||
CREATE INDEX prefix_course_modules_module_idx ON prefix_course_modules (module);
|
||||
CREATE INDEX prefix_course_modules_instance_idx ON prefix_course_modules (instance);
|
||||
CREATE INDEX prefix_course_modules_deleted_idx ON prefix_course_modules (deleted);
|
||||
|
||||
CREATE TABLE prefix_course_sections (
|
||||
id SERIAL PRIMARY KEY,
|
||||
course integer NOT NULL default '0',
|
||||
@@ -85,6 +93,8 @@ CREATE TABLE prefix_course_sections (
|
||||
visible integer NOT NULL default '1'
|
||||
);
|
||||
|
||||
CREATE INDEX prefix_course_sections_coursesection_idx ON prefix_course_sections (course,section);
|
||||
|
||||
CREATE TABLE prefix_event (
|
||||
id SERIAL PRIMARY KEY,
|
||||
name varchar(255) NOT NULL default '',
|
||||
@@ -104,6 +114,8 @@ CREATE TABLE prefix_event (
|
||||
|
||||
CREATE INDEX prefix_event_courseid_idx ON prefix_event (courseid);
|
||||
CREATE INDEX prefix_event_userid_idx ON prefix_event (userid);
|
||||
CREATE INDEX prefix_event_timestart_idx ON prefix_event (timestart);
|
||||
CREATE INDEX prefix_event_timeduration_idx ON prefix_event (timeduration);
|
||||
|
||||
CREATE TABLE prefix_groups (
|
||||
id SERIAL PRIMARY KEY,
|
||||
@@ -127,6 +139,7 @@ CREATE TABLE prefix_groups_members (
|
||||
);
|
||||
|
||||
CREATE INDEX prefix_groups_members_idx ON prefix_groups_members (groupid);
|
||||
CREATE INDEX prefix_groups_members_userid_idx ON prefix_groups_members (userid);
|
||||
|
||||
CREATE TABLE prefix_log (
|
||||
id SERIAL PRIMARY KEY,
|
||||
@@ -162,6 +175,8 @@ CREATE TABLE prefix_modules (
|
||||
visible integer NOT NULL default '1'
|
||||
);
|
||||
|
||||
CREATE INDEX prefix_modules_name_idx ON prefix_modules (name);
|
||||
|
||||
CREATE TABLE prefix_scale (
|
||||
id SERIAL PRIMARY KEY,
|
||||
courseid integer NOT NULL default '0',
|
||||
@@ -172,6 +187,8 @@ CREATE TABLE prefix_scale (
|
||||
timemodified integer NOT NULL default '0'
|
||||
);
|
||||
|
||||
CREATE INDEX prefix_scale_courseid_idx ON prefix_scale (courseid);
|
||||
|
||||
|
||||
CREATE TABLE prefix_cache_filters (
|
||||
id SERIAL PRIMARY KEY,
|
||||
@@ -235,11 +252,16 @@ CREATE TABLE prefix_user (
|
||||
CONSTRAINT prefix_user_username_uk UNIQUE (username)
|
||||
);
|
||||
|
||||
CREATE INDEX prefix_user_idnumber_idx ON prefix_user (idnumber);
|
||||
CREATE INDEX prefix_user_auth_idx ON prefix_user (auth);
|
||||
|
||||
CREATE TABLE prefix_user_admins (
|
||||
id SERIAL PRIMARY KEY,
|
||||
userid integer NOT NULL default '0'
|
||||
);
|
||||
|
||||
CREATE INDEX prefix_user_admins_userid_idx ON prefix_user_admins (userid);
|
||||
|
||||
CREATE TABLE prefix_user_preferences (
|
||||
id SERIAL PRIMARY KEY,
|
||||
userid integer NOT NULL default '0',
|
||||
@@ -260,6 +282,8 @@ CREATE TABLE prefix_user_students (
|
||||
);
|
||||
|
||||
CREATE INDEX prefix_user_students_courseuserid_idx ON prefix_user_students (course,userid);
|
||||
CREATE INDEX prefix_user_students_userid_idx ON prefix_user_students (userid);
|
||||
CREATE INDEX prefix_user_students_timeaccess_idx ON prefix_user_students (timeaccess);
|
||||
|
||||
CREATE TABLE prefix_user_teachers (
|
||||
id SERIAL PRIMARY KEY,
|
||||
@@ -275,14 +299,17 @@ CREATE TABLE prefix_user_teachers (
|
||||
);
|
||||
|
||||
CREATE INDEX prefix_user_teachers_courseuserid_idx ON prefix_user_teachers (course,userid);
|
||||
CREATE INDEX prefix_user_teachers_userid_idx ON prefix_user_teachers (userid);
|
||||
|
||||
CREATE TABLE prefix_user_coursecreators (
|
||||
id SERIAL8 PRIMARY KEY,
|
||||
userid int8 NOT NULL default '0'
|
||||
);
|
||||
|
||||
INSERT INTO prefix_log_display VALUES ('user', 'view', 'user', 'CONCAT(firstname," ",lastname)');
|
||||
INSERT INTO prefix_log_display VALUES ('course', 'user report', 'user', 'CONCAT(firstname," ",lastname)');
|
||||
CREATE INDEX prefix_user_coursecreators_userid_idx ON prefix_user_coursecreators (userid);
|
||||
|
||||
INSERT INTO prefix_log_display VALUES ('user', 'view', 'user', 'firstname||\' \'||lastname');
|
||||
INSERT INTO prefix_log_display VALUES ('course', 'user report', 'user', 'firstname||\' \'||lastname');
|
||||
INSERT INTO prefix_log_display VALUES ('course', 'view', 'course', 'fullname');
|
||||
INSERT INTO prefix_log_display VALUES ('course', 'update', 'course', 'fullname');
|
||||
INSERT INTO prefix_log_display VALUES ('course', 'enrol', 'course', 'fullname');
|
||||
|
||||
Reference in New Issue
Block a user