Title: [opsview] [5284] Apply further speedups to ndoutils_configdumpend
Revision
5284
Author
dferguson
Date
2010-11-02 16:20:47 +0000 (Tue, 02 Nov 2010)

Log Message

Apply further speedups to ndoutils_configdumpend

Rearrange some of the queries slightly

Modified Paths

Modified: trunk/opsview-core/bin/ndoutils_configdumpend
===================================================================
--- trunk/opsview-core/bin/ndoutils_configdumpend	2010-11-02 15:53:48 UTC (rev 5283)
+++ trunk/opsview-core/bin/ndoutils_configdumpend	2010-11-02 16:20:47 UTC (rev 5284)
@@ -77,6 +77,7 @@
 }
 
 my $table;
+my $temp_table;
 
 # Matches contacts between runtime and opsview
 $table = copy_table('opsview_contacts');
@@ -95,10 +96,10 @@
 # Matches contacts with services based on contactgroups
 # Note: if a contact is marked against a service manually, this will not get picked up
 # Note: duplicate rows are ignored because of the intermediate table
-my $temp_table = copy_table( 'opsview_contact_services', "temporary" );
+$table = copy_table('opsview_contact_services');
 $dbh->do( "
-INSERT INTO $temp_table 
-SELECT c.id, s.service_object_id
+INSERT INTO $table 
+SELECT DISTINCT c.id, s.service_object_id
 FROM
  opsview_contacts c,
  nagios_contactgroup_members cgm,
@@ -112,12 +113,6 @@
  AND scg.service_id = s.service_id
  AND s.config_type = 1
 " );
-$table = copy_table('opsview_contact_services');
-$dbh->do( "
-INSERT INTO $table
-SELECT DISTINCT contactid,service_object_id
-FROM $temp_table
-" );
 rename_table($table);
 
 # Copies hostgroup table from opsview
@@ -235,16 +230,18 @@
 
 # Make a generic objects table (primarily for joining to nagios_statechanges)
 $table = copy_table('opsview_contact_objects');
+$logger->debug('Running first insert');
 $dbh->do( "
 INSERT INTO $table
-(
-SELECT contactid, host_object_id
-FROM opsview_contact_hosts
-) UNION (
 SELECT contactid, service_object_id
 FROM opsview_contact_services
-)
 " );
+$logger->debug('Running second insert');
+$dbh->do( "
+INSERT INTO $table
+SELECT contactid, host_object_id
+FROM opsview_contact_hosts
+" );
 rename_table($table);
 
 $temp_table = copy_table( 'opsview_viewports', 'temporary' );

_______________________________________________
Opsview-checkins mailing list
[email protected]
http://lists.opsview.org/lists/listinfo/opsview-checkins

Reply via email to