From b23935b8dc1e85c2299a70e1e775d925d9bbd388 Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Sun, 15 Feb 2015 20:30:28 -0800 Subject: [PATCH] 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.) --- PBot/MessageHistory_SQLite.pm | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/PBot/MessageHistory_SQLite.pm b/PBot/MessageHistory_SQLite.pm index 5c9c222e..e564a9f9 100644 --- a/PBot/MessageHistory_SQLite.pm +++ b/PBot/MessageHistory_SQLite.pm @@ -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; };