Significant improvements in arpwalk performance by adding an additional index to node_ip and reduction in database calls

This commit is contained in:
Eric A. Miller
2013-12-09 22:52:08 -05:00
parent d31655e86d
commit 8690fe0272
4 changed files with 17 additions and 11 deletions

View File

@@ -117,25 +117,21 @@ sub store_arp {
schema('netdisco')->txn_do(sub {
my $current = schema('netdisco')->resultset('NodeIp')
->search({ip => $ip, -bool => 'active'})
->search(undef, {
columns => [qw/mac ip/],
order_by => [qw/mac ip/],
for => 'update'
});
$current->first; # lock rows
$current->update({active => \'false'});
->search(
{ ip => $ip, -bool => 'active'},
{ columns => [qw/mac ip/] })->update({active => \'false'});
schema('netdisco')->resultset('NodeIp')
->search({'me.mac' => $mac, 'me.ip' => $ip})
->update_or_create(
{
mac => $mac,
ip => $ip,
dns => $name,
active => \'true',
time_last => \$now,
},
{
order_by => [qw/mac ip/],
key => 'primary',
for => 'update',
});
});

View File

@@ -8,7 +8,7 @@ use base 'DBIx::Class::Schema';
__PACKAGE__->load_namespaces;
our $VERSION = 29; # schema version used for upgrades, keep as integer
our $VERSION = 31; # schema version used for upgrades, keep as integer
use Path::Class;
use File::Basename;

View File

@@ -0,0 +1,6 @@
BEGIN;
CREATE INDEX node_ip_idx_ip_active ON node_ip (ip, active);
COMMIT;