Improvement on delete_old_thresholds

Support questions about the Threshold plugin

Moderators: Developers, Moderators

Post Reply
ianturo
Posts: 1
Joined: Wed Oct 10, 2012 11:55 am

Improvement on delete_old_thresholds

Post by ianturo »

Hi,

We use "thold" plugin and it manage more than 12000 items and we see that the page of thold list, takes more than 10 seconds to display. In a review the code I found a nested loop that can be improved with a LEFT JOIN, this is the new code for the delete_old_thresholds function, on the thold_functions.php file:

Code: Select all

function delete_old_thresholds () {
        //$result = db_fetch_assoc('SELECT id, data_id, rra_id FROM thold_data');
        $result = db_fetch_assoc('SELECT a.id, data_id, rra_id FROM thold_data a  LEFT JOIN data_template_rrd b  ON (b.id=a.data_id) WHERE data_source_name is null');
        if (sizeof($result)) {
        foreach ($result as $row) {
                //$ds_item_desc = db_fetch_assoc('select id, data_source_name from data_template_rrd where id = ' . $row['data_id']);
                //if (!isset($ds_item_desc[0]['data_source_name'])) {
                db_execute('DELETE FROM thold_data WHERE id=' . $row['id']);
                db_execute('DELETE FROM plugin_thold_threshold_contact WHERE thold_id=' . $row['id']);
                //}
                }
        }
}
cigamit
Developer
Posts: 3369
Joined: Thu Apr 07, 2005 3:29 pm
Location: B/CS Texas
Contact:

Re: Improvement on delete_old_thresholds

Post by cigamit »

Thanks! I have applied this to SVN.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest