Permalink
Browse files

Indexes on forum and version bump

  • Loading branch information...
1 parent 726f4ca commit e8f491f24917fe3ec4b6b7a906654cdbd284643c mjollnir_ committed Nov 18, 2004
Showing with 75 additions and 7 deletions.
  1. +17 −1 mod/forum/db/mysql.php
  2. +15 −5 mod/forum/db/mysql.sql
  3. +19 −0 mod/forum/db/postgres7.php
  4. +23 −0 mod/forum/db/postgres7.sql
  5. +1 −1 mod/forum/version.php
View
@@ -130,9 +130,25 @@ function forum_upgrade($oldversion) {
if ($oldversion < 2004070700) { // This may be redoing it from STABLE but that's OK
table_column("forum_discussions", "groupid", "groupid", "integer", "10", "", "0", "");
}
+
+ if ($oldversion < 2004081801) {
+ execute_sql(" ALTER TABLE `{$CFG->prefix}forum_posts` ADD INDEX {$CFG->prefix}forum_posts_parent_idx (parent) ");
+ execute_sql(" ALTER TABLE `{$CFG->prefix}forum_posts` ADD INDEX {$CFG->prefix}forum_posts_discussion_idx (discussion) ");
+ execute_sql(" ALTER TABLE `{$CFG->prefix}forum_posts` ADD INDEX {$CFG->prefix}forum_posts_userid_idx (userid) ");
+ execute_sql(" ALTER TABLE `{$CFG->prefix}forum_discussions` ADD INDEX {$CFG->prefix}forum_discussions_forum_idx (forum) ");
+ execute_sql(" ALTER TABLE `{$CFG->prefix}forum_discussions` ADD INDEX {$CFG->prefix}forum_discussions_userid_idx (userid) ");
+ }
- return true;
+ if ($oldversion < 2004111200) {
+ modify_database('','ALTER TABLE prefix_forum ADD INDEX course (course);');
+ modify_database('','ALTER TABLE prefix_forum_ratings ADD INDEX userid (userid);');
+ modify_database('','ALTER TABLE prefix_forum_ratings ADD INDEX post (post);');
+ modify_database('','ALTER TABLE prefix_forum_subscriptions ADD INDEX userid (userid);');
+ modify_database('','ALTER TABLE prefix_forum_subscriptions ADD INDEX forum (forum);');
+ }
+ return true;
+
}
View
@@ -20,7 +20,8 @@ CREATE TABLE prefix_forum (
rssarticles tinyint(2) unsigned NOT NULL default '0',
timemodified int(10) unsigned NOT NULL default '0',
PRIMARY KEY (id),
- UNIQUE KEY id (id)
+ UNIQUE KEY id (id),
+ KEY course (course)
) COMMENT='Forums contain and structure discussion';
# --------------------------------------------------------
@@ -39,7 +40,9 @@ CREATE TABLE prefix_forum_discussions (
assessed tinyint(1) NOT NULL default '1',
timemodified int(10) unsigned NOT NULL default '0',
usermodified int(10) unsigned NOT NULL default '0',
- PRIMARY KEY (id)
+ PRIMARY KEY (id),
+ KEY prefix_forum_discussions_forum_idx (forum),
+ KEY prefix_forum_discussions_userid_idx (userid)
) COMMENT='Forums are composed of discussions';
# --------------------------------------------------------
@@ -60,7 +63,10 @@ CREATE TABLE prefix_forum_posts (
format tinyint(2) NOT NULL default '0',
attachment VARCHAR(100) NOT NULL default '',
totalscore tinyint(4) NOT NULL default '0',
- PRIMARY KEY (id)
+ PRIMARY KEY (id),
+ KEY prefix_forum_posts_parent_idx (parent),
+ KEY prefix_forum_posts_discussion_idx (discussion),
+ KEY prefix_forum_posts_userid_idx (userid)
) COMMENT='All posts are stored in this table';
# --------------------------------------------------------
@@ -89,7 +95,9 @@ CREATE TABLE prefix_forum_ratings (
post int(10) unsigned NOT NULL default '0',
time int(10) unsigned NOT NULL default '0',
rating tinyint(4) NOT NULL default '0',
- PRIMARY KEY (id)
+ PRIMARY KEY (id),
+ KEY userid (userid),
+ KEY post (post)
) COMMENT='Contains user ratings for individual posts';
# --------------------------------------------------------
@@ -102,7 +110,9 @@ CREATE TABLE prefix_forum_subscriptions (
userid int(10) unsigned NOT NULL default '0',
forum int(10) unsigned NOT NULL default '0',
PRIMARY KEY (id),
- UNIQUE KEY id (id)
+ UNIQUE KEY id (id),
+ KEY userid (userid),
+ KEY forum (forum)
) COMMENT='Keeps track of who is subscribed to what forum';
# --------------------------------------------------------
View
@@ -62,6 +62,25 @@ function forum_upgrade($oldversion) {
);");
}
+ if ($oldversion < 2004081801) {
+ execute_sql(" CREATE INDEX {$CFG->prefix}forum_posts_parent_idx ON {$CFG->prefix}forum_posts (parent) ");
+ execute_sql(" CREATE INDEX {$CFG->prefix}forum_posts_discussion_idx ON {$CFG->prefix}forum_posts (discussion) ");
+ execute_sql(" CREATE INDEX {$CFG->prefix}forum_posts_userid_idx ON {$CFG->prefix}forum_posts (userid) ");
+ execute_sql(" CREATE INDEX {$CFG->prefix}forum_discussions_forum_idx ON {$CFG->prefix}forum_discussions (forum) ");
+ execute_sql(" CREATE INDEX {$CFG->prefix}forum_discussions_userid_idx ON {$CFG->prefix}forum_discussions (userid) ");
+ }
+
+ if ($oldversion < 2004111200) {
+ modify_database('','CREATE INDEX prefix_forum_course_idx ON prefix_forum (course);');
+ modify_database('','CREATE INDEX prefix_forum_queue_userid_idx ON prefix_forum_queue (userid);');
+ modify_database('','CREATE INDEX prefix_forum_queue_discussion_idx ON prefix_forum_queue (discussionid);');
+ modify_database('','CREATE INDEX prefix_forum_queue_postid_idx ON prefix_forum_queue (postid);');
+ modify_database('','CREATE INDEX prefix_forum_ratings_userid_idx ON prefix_forum_ratings (userid);');
+ modify_database('','CREATE INDEX prefix_forum_ratings_post_idx ON prefix_forum_ratings (post);');
+ modify_database('','CREATE INDEX prefix_forum_subscriptions_userid_idx ON prefix_forum_subscriptions (userid);');
+ modify_database('','CREATE INDEX prefix_forum_subscriptions_forum_idx ON prefix_forum_subscriptions (forum);');
+ }
+
return true;
}
View
@@ -20,6 +20,8 @@ CREATE TABLE prefix_forum (
rssarticles integer NOT NULL default '0',
timemodified integer NOT NULL default '0'
);
+
+CREATE INDEX prefix_forum_course_idx ON prefix_forum (course);
# --------------------------------------------------------
#
@@ -38,6 +40,10 @@ CREATE TABLE prefix_forum_discussions (
timemodified integer NOT NULL default '0',
usermodified integer NOT NULL default '0'
);
+
+CREATE INDEX prefix_forum_discussions_forum_idx ON prefix_forum_discussions (forum);
+CREATE INDEX prefix_forum_discussions_userid_idx ON prefix_forum_discussions (userid);
+
# --------------------------------------------------------
#
@@ -58,6 +64,12 @@ CREATE TABLE prefix_forum_posts (
attachment VARCHAR(100) NOT NULL default '',
totalscore integer NOT NULL default '0'
);
+
+CREATE INDEX prefix_forum_posts_discussion_idx ON prefix_forum_posts (discussion);
+CREATE INDEX prefix_forum_posts_parent_idx ON prefix_forum_posts (parent);
+CREATE INDEX prefix_forum_posts_userid_idx ON prefix_forum_posts (userid);
+
+
# --------------------------------------------------------
#
@@ -71,6 +83,9 @@ CREATE TABLE prefix_forum_queue (
postid integer default 0 NOT NULL
);
+CREATE INDEX prefix_forum_queue_userid_idx ON prefix_forum_queue (userid);
+CREATE INDEX prefix_forum_queue_discussion_idx ON prefix_forum_queue (discussionid);
+CREATE INDEX prefix_forum_queue_postid_idx ON prefix_forum_queue (postid);
# --------------------------------------------------------
@@ -85,6 +100,10 @@ CREATE TABLE prefix_forum_ratings (
time integer NOT NULL default '0',
rating integer NOT NULL default '0'
);
+
+CREATE INDEX prefix_forum_ratings_userid_idx ON prefix_forum_ratings (userid);
+CREATE INDEX prefix_forum_ratings_post_idx ON prefix_forum_ratings (post);
+
# --------------------------------------------------------
#
@@ -96,6 +115,10 @@ CREATE TABLE prefix_forum_subscriptions (
userid integer NOT NULL default '0',
forum integer NOT NULL default '0'
);
+
+CREATE INDEX prefix_forum_subscriptions_userid_idx ON prefix_forum_subscriptions (userid);
+CREATE INDEX prefix_forum_subscriptions_forum_idx ON prefix_forum_subscriptions (forum);
+
# --------------------------------------------------------
#
View
@@ -5,7 +5,7 @@
// This fragment is called by /admin/index.php
////////////////////////////////////////////////////////////////////////////////
-$module->version = 2004081800;
+$module->version = 2004111200;
$module->requires = 2004082300; // Requires this Moodle version
$module->cron = 60;

0 comments on commit e8f491f

Please sign in to comment.