Create SQLite index for Messages table

This significantly speeds up certain SQL actions on
the Messages table that were done for anti-flood detection.

The bot should now be significantly more quicker to catch
floods promptly without delay.

(Also, comment out some logging messages. Perhaps revisit this
and wrap them with a debug registry variable instead.)
This commit is contained in:
Pragmatic Software 2015-02-15 20:30:28 -08:00
parent 19788eec47
commit b23935b8dc
1 changed files with 7 additions and 0 deletions

View File

@ -117,6 +117,9 @@ CREATE TABLE IF NOT EXISTS Messages (
)
SQL
$self->{dbh}->do('CREATE INDEX IF NOT EXISTS MsgIdx1 ON Messages(id, channel, mode)');
$self->{dbh}->begin_work();
};
$self->{pbot}->{logger}->log($@) if $@;
@ -302,18 +305,22 @@ sub get_message_account {
$sth->execute();
my $rows = $sth->fetchall_arrayref({});
=cut
foreach my $row (@$rows) {
$self->{pbot}->{logger}->log("Found matching nick $row->{hostmask} with id $row->{id}\n");
}
=cut
if(not defined $rows->[0]) {
$sth->bind_param(1, "%!$user\@$host");
$sth->execute();
$rows = $sth->fetchall_arrayref({});
=cut
foreach my $row (@$rows) {
$self->{pbot}->{logger}->log("Found matching user\@host mask $row->{hostmask} with id $row->{id}\n");
}
=cut
}
return $rows;
};