mirror of https://github.com/pragma-/pbot.git
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:
parent
19788eec47
commit
b23935b8dc
|
@ -117,6 +117,9 @@ CREATE TABLE IF NOT EXISTS Messages (
|
||||||
)
|
)
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
|
|
||||||
|
$self->{dbh}->do('CREATE INDEX IF NOT EXISTS MsgIdx1 ON Messages(id, channel, mode)');
|
||||||
|
|
||||||
$self->{dbh}->begin_work();
|
$self->{dbh}->begin_work();
|
||||||
};
|
};
|
||||||
$self->{pbot}->{logger}->log($@) if $@;
|
$self->{pbot}->{logger}->log($@) if $@;
|
||||||
|
@ -302,18 +305,22 @@ sub get_message_account {
|
||||||
$sth->execute();
|
$sth->execute();
|
||||||
my $rows = $sth->fetchall_arrayref({});
|
my $rows = $sth->fetchall_arrayref({});
|
||||||
|
|
||||||
|
=cut
|
||||||
foreach my $row (@$rows) {
|
foreach my $row (@$rows) {
|
||||||
$self->{pbot}->{logger}->log("Found matching nick $row->{hostmask} with id $row->{id}\n");
|
$self->{pbot}->{logger}->log("Found matching nick $row->{hostmask} with id $row->{id}\n");
|
||||||
}
|
}
|
||||||
|
=cut
|
||||||
|
|
||||||
if(not defined $rows->[0]) {
|
if(not defined $rows->[0]) {
|
||||||
$sth->bind_param(1, "%!$user\@$host");
|
$sth->bind_param(1, "%!$user\@$host");
|
||||||
$sth->execute();
|
$sth->execute();
|
||||||
$rows = $sth->fetchall_arrayref({});
|
$rows = $sth->fetchall_arrayref({});
|
||||||
|
|
||||||
|
=cut
|
||||||
foreach my $row (@$rows) {
|
foreach my $row (@$rows) {
|
||||||
$self->{pbot}->{logger}->log("Found matching user\@host mask $row->{hostmask} with id $row->{id}\n");
|
$self->{pbot}->{logger}->log("Found matching user\@host mask $row->{hostmask} with id $row->{id}\n");
|
||||||
}
|
}
|
||||||
|
=cut
|
||||||
}
|
}
|
||||||
return $rows;
|
return $rows;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue