Add menu action to update database indices
This commit is contained in:
+65
-1
@@ -864,7 +864,71 @@ my %handlers = (
|
|||||||
'<', Util::shell_quote($dump_file) );
|
'<', Util::shell_quote($dump_file) );
|
||||||
},
|
},
|
||||||
|
|
||||||
# '33. Repair fspgroup Write Groups (Mars)' => sub {
|
'33. Add Query Indices (Mars)' => sub {
|
||||||
|
|
||||||
|
# Add indices to accelerate queries:
|
||||||
|
# - fspgroup.eq_class
|
||||||
|
# - fsppilot.pilot_class
|
||||||
|
my @dbs = Mars::db_list();
|
||||||
|
my @dbs_with_notes;
|
||||||
|
foreach my $db (@dbs) {
|
||||||
|
my $info =
|
||||||
|
Util::read_experiment_info( $db =~ s/smchurla_//r =~ s/:/-/gr );
|
||||||
|
|
||||||
|
push @dbs_with_notes,
|
||||||
|
( defined $info && length($info) > 0 )
|
||||||
|
? sprintf( "%-60s (%s)", $db, $info )
|
||||||
|
: $db;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Pick databases
|
||||||
|
my @selected_dbs =
|
||||||
|
TUI::select_from_list( "Select Databases to Add Indices To",
|
||||||
|
1, @dbs_with_notes );
|
||||||
|
die "No database selected" unless @selected_dbs;
|
||||||
|
|
||||||
|
@selected_dbs =
|
||||||
|
map { s/(.*?)\s+\(.+\)$/$1/r } @selected_dbs;
|
||||||
|
|
||||||
|
my @indices = (
|
||||||
|
[
|
||||||
|
'fspgroup', 'eq_class',
|
||||||
|
'variant_id, instr2, data_physical_address'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'fsppilot', 'pilot_class',
|
||||||
|
'variant_id, known_outcome, instr2, data_physical_address'
|
||||||
|
],
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach my $db (@selected_dbs) {
|
||||||
|
say "Adding indices to $db...";
|
||||||
|
|
||||||
|
foreach my $index (@indices) {
|
||||||
|
my ( $table, $name, $columns ) = @$index;
|
||||||
|
|
||||||
|
my ($exists) = Mars::db_selectrow(
|
||||||
|
"SELECT COUNT(*) FROM information_schema.STATISTICS
|
||||||
|
WHERE TABLE_SCHEMA = '$db'
|
||||||
|
AND TABLE_NAME = '$table'
|
||||||
|
AND INDEX_NAME = '$name'"
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($exists) {
|
||||||
|
say " - $table.$name already exists, skipping";
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
|
||||||
|
say " - Adding $table.$name ($columns)...";
|
||||||
|
Mars::db_do(
|
||||||
|
"ALTER TABLE `$db`.`$table` ADD KEY `$name` ($columns)");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
say "Added indices";
|
||||||
|
},
|
||||||
|
|
||||||
|
# '34. Repair fspgroup Write Groups (Mars)' => sub {
|
||||||
#
|
#
|
||||||
# # Retroactively fixes (hopefully) the missing equivalence class
|
# # Retroactively fixes (hopefully) the missing equivalence class
|
||||||
# # mappings (EC <-> Pilot) the BasicPruner misses (because it maps
|
# # mappings (EC <-> Pilot) the BasicPruner misses (because it maps
|
||||||
|
|||||||
Reference in New Issue
Block a user