Remove items from a menu based on node type efficiently
Gathering node paths for the book_section nodes in a function cached with drupal_static and using removing items from the menu based on that, rather than loading node objects for each menu item removed thousands or surplus DB queries. 

Refactored code

function amoss_menu_link(&amp;$variables) {

  // Hide book sections from the menu;.
  if (isset($variables['element']['#original_link']['link_path'])) {
    if ($variables['element']['#original_link']['menu_name'] == 'book-toc-1') {
        $book_sections = book_modifications_get_book_section_paths();

      if ( in_array( $variables['element']['#original_link']['link_path'], $book_sections ) ) {
        return '';
      }
    }
  }

  // Output a menu link.
  $element = $variables['element'];
  $sub_menu = '';

  if ($element['#below']) {
    $sub_menu = drupal_render($element['#below']);
  }
  $output = l($element['#title'], $element['#href'], $element['#localized_options']);
  return '&lt;li' . drupal_attributes($element['#attributes']) . '&gt;' . $output . $sub_menu . "&lt;/li&gt;\n";
}



function book_modifications_get_book_section_paths() {
    $book_section_paths = &amp;drupal_static(__FUNCTION__);

    if (!isset($book_section_paths)) {
        $book_section_paths = array();
        $nids = db_select('node', 'n')
        -&gt;fields('n', array('nid'))
        -&gt;condition('type', 'book_section', '=')
        -&gt;execute()
        -&gt;fetchCol();

        foreach ( $nids as $id ) {
            $book_section_paths[] = 'node/'.$id;
        }

    }

    return $book_section_paths;
}