Improved indexing for improved performance on the course page, when viewing

logs and when viewing lists of users ... thanks to Eloy for the one on the log file.
This commit is contained in:
moodler
2003-07-28 02:51:56 +00:00
parent 8b0ef9b0cb
commit a8fa25d18d
5 changed files with 26 additions and 5 deletions
+7
View File
@@ -405,6 +405,13 @@ function main_upgrade($oldversion=0) {
table_column("course_sections", "sequence", "sequence", "text", "", "", "", "", "");
}
if ($oldversion < 2003072800) {
print_simple_box("The following database index improves performance, but can be quite large - if you are upgrading and you have problems with a limited quota you may want to delete this index later from the '{$CFG->prefix}log' table in your database", "center", "50%", "$THEME->cellheading", "20", "noticebox");
execute_sql(" ALTER TABLE `{$CFG->prefix}log` ADD INDEX timecoursemoduleaction (time,course,module,action) ");
execute_sql(" ALTER TABLE `{$CFG->prefix}user_students` ADD INDEX courseuserid (course,userid) ");
execute_sql(" ALTER TABLE `{$CFG->prefix}user_teachers` ADD INDEX courseuserid (course,userid) ");
}
return $result;
}
+5 -2
View File
@@ -131,6 +131,7 @@ CREATE TABLE `prefix_log` (
`url` varchar(100) NOT NULL default '',
`info` varchar(255) NOT NULL default '',
PRIMARY KEY (`id`),
KEY `timecoursemoduleaction` (time,course,module,action),
KEY `coursemoduleaction` (course,module,action),
KEY `courseuserid` (course,userid)
) TYPE=MyISAM COMMENT='Every action is logged as far as possible.';
@@ -233,7 +234,8 @@ CREATE TABLE `prefix_user_students` (
`timeend` int(10) unsigned NOT NULL default '0',
`time` int(10) unsigned NOT NULL default '0',
PRIMARY KEY (`id`),
UNIQUE KEY `id` (`id`)
UNIQUE KEY `id` (`id`),
KEY `courseuserid` (course,userid)
) TYPE=MyISAM;
# --------------------------------------------------------
@@ -248,7 +250,8 @@ CREATE TABLE `prefix_user_teachers` (
`authority` int(10) NOT NULL default '3',
`role` varchar(40) NOT NULL default '',
PRIMARY KEY (`id`),
UNIQUE KEY `id` (`id`)
UNIQUE KEY `id` (`id`),
KEY `courseuserid` (course,userid)
) TYPE=MyISAM COMMENT='One record per teacher per course';
#
+7
View File
@@ -176,6 +176,13 @@ function main_upgrade($oldversion=0) {
table_column("course_sections", "sequence", "sequence", "text", "", "", "", "", "");
}
if ($oldversion < 2003072800) {
print_simple_box("The following database index improves performance, but can be quite large - if you are upgrading and you have problems with a limited quota you may want to delete this index later from the '{$CFG->prefix}log' table in your database", "center", "50%", "$THEME->cellheading", "20", "noticebox");
execute_sql(" CREATE INDEX {$CFG->prefix}log_timecoursemoduleaction_idx ON {$CFG->prefix}log (time,course,module,action) ");
execute_sql(" CREATE INDEX {$CFG->prefix}user_students_courseuserid_idx ON {$CFG->prefix}user_students (course,userid) ");
execute_sql(" CREATE INDEX {$CFG->prefix}user_teachers_courseuserid_idx ON {$CFG->prefix}user_teachers (course,userid) ");
}
return $result;
}
?>
+6 -2
View File
@@ -76,7 +76,7 @@ CREATE TABLE prefix_log (
);
CREATE INDEX prefix_log_coursemoduleaction_idx ON prefix_log (course,module,action);
CREATE INDEX prefix_log_timecoursemoduleaction_idx ON prefix_log (time,course,module,action);
CREATE INDEX prefix_log_courseuserid_idx ON prefix_log (course,userid);
CREATE TABLE prefix_log_display (
@@ -147,6 +147,8 @@ CREATE TABLE prefix_user_students (
time integer NOT NULL default '0'
);
CREATE INDEX prefix_user_students_courseuserid_idx ON prefix_user_students (course,userid);
CREATE TABLE prefix_user_teachers (
id SERIAL PRIMARY KEY,
userid integer NOT NULL default '0',
@@ -155,7 +157,9 @@ CREATE TABLE prefix_user_teachers (
role varchar(40) NOT NULL default ''
);
CREATE TABLE mdl_user_coursecreators (
CREATE INDEX prefix_user_teachers_courseuserid_idx ON prefix_user_teachers (course,userid);
CREATE TABLE prefix_user_coursecreators (
id SERIAL8 PRIMARY KEY,
userid int8 NOT NULL default '0'
);
+1 -1
View File
@@ -5,7 +5,7 @@
// database to determine whether upgrades should
// be performed (see lib/db/*.php)
$version = 2003072101; // The current version is a date (YYYYMMDDXX)
$version = 2003072800; // The current version is a date (YYYYMMDDXX)
$release = "1.1 development"; // User-friendly version number