diff --git a/taxonomy_menu.admin.inc b/taxonomy_menu.admin.inc
index 804d582..0275d32 100644
--- a/taxonomy_menu.admin.inc
+++ b/taxonomy_menu.admin.inc
@@ -71,6 +71,15 @@ function taxonomy_menu_form_taxonomy_form_vocabulary(&$form, &$form_state) {
     '#description' => t('Every time a term is added/deleted/modified, the corresponding menu link will be altered too.'),
     '#default_value' => taxonomy_menu_variable_get('sync', $vid, $defaults['sync']),
   );
+  // Max depth
+  $variable_name = _taxonomy_menu_build_variable('max_depth', $vid);
+  $form['taxonomy_menu']['max_depth'] = array(
+    '#type' => 'select',
+    '#title' => t('Max depth'),
+    '#description' => t('Limit how many levels of the taxonomy tree to process. Useful if you have a very large tree of taxonomy terms, and only want to provide a menu for the first several levels. 0 for no limit.'),
+    '#options' => array(0 => t('All'), 1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9),
+    '#default_value' => taxonomy_menu_variable_get('max_depth', $vid, $defaults['max_depth']),
+  );
   // Rebuild
   $variable_name = _taxonomy_menu_build_variable('rebuild', $vid);
   $form['taxonomy_menu']['rebuild'] = array(
@@ -313,6 +322,7 @@ function taxonomy_menu_taxonomy_menu_vocabulary_settings() {
     'vocab_menu' => 0,
     'path' => 0,
     'sync' => TRUE,
+    'max_depth' => 0,
     'rebuild' => FALSE,
     'expanded' => TRUE,
     'term_item_description' => FALSE,
diff --git a/taxonomy_menu.module b/taxonomy_menu.module
index 3c20a4a..b232d96 100644
--- a/taxonomy_menu.module
+++ b/taxonomy_menu.module
@@ -64,7 +64,10 @@ function taxonomy_menu_menu_links_insert($vid) {
   // Get a list of all the taxonomy terms for that vocabulary and process them
   // using the bacth API.
   $menu_name = taxonomy_menu_variable_get('vocab_menu', $vid, FALSE);
-  $terms = taxonomy_get_tree($vid, 0, NULL, TRUE);
+  $depth = taxonomy_menu_variable_get('max_depth', $vid, 0);
+  if ($depth == 0)
+    $depth = NULL;
+  $terms = taxonomy_get_tree($vid, 0, $depth, TRUE);
   _taxonomy_menu_save_menu_links_batch($terms, $menu_name);

   menu_cache_clear($menu_name);
@@ -444,7 +444,9 @@ function _taxonomy_menu_termapi_helper($term, $operation) {
   // option has been checked.
   $menu_name = taxonomy_menu_variable_get('vocab_menu', $term->vid, 0);
   $sync = taxonomy_menu_variable_get('sync', $term->vid, 0);
-  if ($menu_name && $sync) {
+  $depth = taxonomy_menu_variable_get('max_depth', $term->vid, 0);
+  $term_depth = _taxomonmy_menu_term_depth($term->tid);
+  if ($menu_name && $sync && ($depth >= $term_depth || $depth == 0)) {
     switch ($operation) {
       case 'insert':
         $text = 'Added term %term to taxonomy menu %menu_name.';
diff --git a/taxonomy_menu.database.inc b/taxonomy_menu.database.inc
index 7db4fcf..11c5218 100644
--- a/taxonomy_menu.database.inc
+++ b/taxonomy_menu.database.inc
@@ -259,3 +259,19 @@ function _taxonomy_menu_get_vid_by_tid($tids) {
     return $result->fetchAllAssoc('vid');
   }
 }
+
+/**
+ * Get term depth from a tid.
+ */
+function _taxomonmy_menu_term_depth($tid) {
+  $limit = 5;
+  $depth = 0;
+  while ($parent = db_select('taxonomy_term_hierarchy', 't') ->condition('tid', $tid, '=') ->fields('t') ->execute() ->fetchAssoc()) {
+    $depth ++;
+    $tid = $parent['parent'];
+    if ($depth > $limit) {
+      break;
+    }
+  }
+  return $depth;
+}

