Significant improvements in arpwalk performance by adding an additional index to node_ip and reduction in database calls
This commit is contained in:
@@ -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',
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
|
||||
BEGIN;
|
||||
|
||||
CREATE INDEX node_ip_idx_ip_active ON node_ip (ip, active);
|
||||
|
||||
COMMIT;
|
||||
Reference in New Issue
Block a user