Programmatically Updating Taxonomy Term I'm looking for a better way to update a set of taxonomy terms. It's currently causing cron to hang which slows down the site substantially. 

    //Look through all of the stocks    
    foreach ($terms_data as $symbol =&gt; $data) {
        //Check to see if term exists in the default vocabulary
        $matching_terms = taxonomy_get_term_by_name($symbol, __DEFAULT_VOCAB_MACHINE_NAME);

        //Loop through existing term(s)
        foreach ($matching_terms as $term) {
            //Load the new vocab term
            $new_term_data = taxonomy_term_load($term-&gt;tid);
            foreach ($data as $k =&gt; $v) {
                //Add in the new data
                $field_name = substr("field_".$k, 0, 31);
                $new_term_data-&gt;{"$field_name"}['und'][0]['value'] = $v;    
            }
            taxonomy_term_save($new_term_data); 
        }
    } //endforeach  


The only way I could figure out how to get it to work was to:


Find the term that matches the $symbol variable
Loop through the matching term (1 term)
Create a new term
Update the exact fields 
Save overtop of the old term


I know there has to be a better way to do this. Any ideas? Thanks in advance!
For those of you interested: the bottleneck is in the taxonomy_term_save() function. 

Following the trail, it led me to the field_sql_storage module (in core) which deletes an existing row and then inserts it. It should really use the built in DB Driver functionality and UPSERT instead of deleting and then inserting.

Working issues (for D8 only): 


https://www.drupal.org/node/1800286#comment-9356897
https://www.drupal.org/node/2239071


As of writing this, no patches have been applied yet. Updating large sets of taxonomy terms will lock up your DB.