added an index on the groupings table for the userId column
This commit is contained in:
parent
1bdbb186aa
commit
3257456df7
2 changed files with 29 additions and 0 deletions
|
|
@ -13,6 +13,8 @@
|
||||||
LIMIT clauses.
|
LIMIT clauses.
|
||||||
- add: SyndicatedContent wobject now has more ways of representing the long
|
- add: SyndicatedContent wobject now has more ways of representing the long
|
||||||
description from the RSS feed.
|
description from the RSS feed.
|
||||||
|
- Added an index on the userId column of the groupings table to speed up
|
||||||
|
queries for groupIds by userId (instead of the usual userIds by groupId)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ my $quiet; # this line required
|
||||||
my $session = start(); # this line required
|
my $session = start(); # this line required
|
||||||
|
|
||||||
# upgrade functions go here
|
# upgrade functions go here
|
||||||
|
addGroupingsIndexOnUserId($session);
|
||||||
fixProfileDataWithoutFields($session);
|
fixProfileDataWithoutFields($session);
|
||||||
buildNewUserProfileTable($session);
|
buildNewUserProfileTable($session);
|
||||||
addAttachmentsToEvents($session);
|
addAttachmentsToEvents($session);
|
||||||
|
|
@ -37,6 +38,32 @@ finish($session); # this line required
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
sub addGroupingsIndexOnUserId {
|
||||||
|
my $session = shift;
|
||||||
|
my $db = $session->db;
|
||||||
|
print qq{\tAdding index on `userId` column in `groupings` table for performance... } unless $quiet;
|
||||||
|
|
||||||
|
# See if we even NEED to add this index, if we don't it just takes up
|
||||||
|
# disk/memory space.
|
||||||
|
my %createTable
|
||||||
|
= $db->quickHash(
|
||||||
|
"SHOW CREATE TABLE `groupings`"
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($createTable{'Create Table'} =~ /KEY\s+`[^`]+`\s+[(]`userId`[)]/) {
|
||||||
|
print " Skipped!\n",
|
||||||
|
"\t\tAn index already exists on the `userId` column in the `groupings` table\n"
|
||||||
|
unless $quiet;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
print "\n\t\tThis may take a while... " unless $quiet;
|
||||||
|
$db->write("ALTER TABLE `groupings` ADD INDEX `userId` (`userId`)");
|
||||||
|
print "DONE!\n" unless $quiet;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
sub fixProfileDataWithoutFields {
|
sub fixProfileDataWithoutFields {
|
||||||
my $session = shift;
|
my $session = shift;
|
||||||
my $db = $session->db;
|
my $db = $session->db;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue